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

Commit 1b85882

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: 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>
1 parent 36971ec commit 1b85882

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
# These are backup files generated by rustfmt
55
**/*.rs.bk
66

7-
.DS_Store
7+
.DS_Store
8+
9+
# The cache for docker container dependency
10+
.cargo
11+
12+
# The cache for chain data in container
13+
.local

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ cargo run -- \
8080

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

83+
### Run in Docker
84+
85+
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.
86+
87+
```bash
88+
./scripts/docker_run.sh
89+
```
90+
91+
If you just want to run the compiled binary,
92+
93+
```bash
94+
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
95+
```
96+
97+
Other commands are similar. Let's try purge the local dev chain here:
98+
99+
```bash
100+
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
101+
```
102+
103+
You can also check whether the code is able to compile or not,
104+
105+
```bash
106+
./scripts/docker_run.sh cargo check
107+
```
108+
83109
## Advanced: Generate Your Own Substrate Node Template
84110

85111
A substrate node template is always based on a certain version of Substrate. You can inspect it by

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: "3.2"
2+
3+
services:
4+
dev:
5+
container_name: node-template
6+
image: parity/rust-builder:latest
7+
working_dir: /var/www/node-template
8+
ports:
9+
- "9944:9944"
10+
environment:
11+
- CARGO_HOME=/var/www/node-template/.cargo
12+
volumes:
13+
- .:/var/www/node-template
14+
- type: bind
15+
source: ./.local
16+
target: /root/.local
17+
command: bash -c "cargo build --release && ./target/release/node-template --dev --ws-external"

scripts/docker_run.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
echo "*** Start Substrate node template ***"
6+
7+
cd $(dirname ${BASH_SOURCE[0]})/..
8+
9+
docker-compose down --remove-orphans
10+
docker-compose run --rm --service-ports dev $@

0 commit comments

Comments
 (0)