Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Use docker to setup a local dev chain (#41)
Browse files Browse the repository at this point in the history
* use docker to setup a local dev chain.

* install docker link

* update command

* Update README.md

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* more commands to start or check a node.

* purge chain in docker

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
  • Loading branch information
kaichaosun and joepetrowski authored May 15, 2020
1 parent 36971ec commit 1b85882
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
# These are backup files generated by rustfmt
**/*.rs.bk

.DS_Store
.DS_Store

# The cache for docker container dependency
.cargo

# The cache for chain data in container
.local
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ cargo run -- \

Additional CLI usage options are available and may be shown by running `cargo run -- --help`.

### Run in Docker

Install [Docker](https://docs.docker.com/get-docker/) first, then run the following command to start a single node development chain. This command will firstly comipile your code, then start a local dev netork.

```bash
./scripts/docker_run.sh
```

If you just want to run the compiled binary,

```bash
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
```

Other commands are similar. Let's try purge the local dev chain here:

```bash
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
```

You can also check whether the code is able to compile or not,

```bash
./scripts/docker_run.sh cargo check
```

## Advanced: Generate Your Own Substrate Node Template

A substrate node template is always based on a certain version of Substrate. You can inspect it by
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.2"

services:
dev:
container_name: node-template
image: parity/rust-builder:latest
working_dir: /var/www/node-template
ports:
- "9944:9944"
environment:
- CARGO_HOME=/var/www/node-template/.cargo
volumes:
- .:/var/www/node-template
- type: bind
source: ./.local
target: /root/.local
command: bash -c "cargo build --release && ./target/release/node-template --dev --ws-external"
10 changes: 10 additions & 0 deletions scripts/docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

echo "*** Start Substrate node template ***"

cd $(dirname ${BASH_SOURCE[0]})/..

docker-compose down --remove-orphans
docker-compose run --rm --service-ports dev $@

0 comments on commit 1b85882

Please sign in to comment.