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: 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>main
parent
36971ec2ee
commit
1b8588241b
|
@ -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
README.md
26
README.md
|
@ -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
|
||||
|
|
|
@ -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"
|
|
@ -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 $@
|
Loading…
Reference in New Issue