Skip to content
Snippets Groups Projects
Unverified Commit 1b858824 authored by kaichao's avatar kaichao Committed by GitHub
Browse files

Use docker to setup a local dev chain (#41)


* use docker to setup a local dev chain.

* install docker link

* update command

* Update README.md

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

* more commands to start or check a node.

* purge chain in docker

Co-authored-by: default avatarjoe petrowski <25483142+joepetrowski@users.noreply.github.com>
parent 36971ec2
No related branches found
No related tags found
No related merge requests found
...@@ -4,4 +4,10 @@ ...@@ -4,4 +4,10 @@
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk
.DS_Store .DS_Store
\ No newline at end of file
# The cache for docker container dependency
.cargo
# The cache for chain data in container
.local
\ No newline at end of file
...@@ -80,6 +80,32 @@ cargo run -- \ ...@@ -80,6 +80,32 @@ cargo run -- \
Additional CLI usage options are available and may be shown by running `cargo run -- --help`. 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 ## 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 A substrate node template is always based on a certain version of Substrate. You can inspect it by
......
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"
#!/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 $@
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment