Skip to content

Commit

Permalink
Update Docker instructions (paritytech#13437)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen authored Mar 8, 2023
1 parent 7c3d279 commit 77c675b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ rls*.log
*.bin
*.iml
scripts/ci/node-template-release/Cargo.lock
bin/node-template/Cargo.lock
substrate.code-workspace
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Substrate is a next-generation framework for blockchain innovation 🚀.

Head to [docs.substrate.io](https://docs.substrate.io) and follow the [installation](https://docs.substrate.io/install/) instructions.
Then try out one of the [tutorials](https://docs.substrate.io/tutorials/).
Refer to the [Docker instructions](./docker/README.md) to quickly run Substrate, Substrate Node Template, Subkey, or to build a chain spec.

## Community & Support

Expand Down
29 changes: 4 additions & 25 deletions bin/node-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

A fresh [Substrate](https://substrate.io/) node, ready for hacking :rocket:

A standalone version of this template is available for each release of Polkadot in the [Substrate Developer Hub Parachain Template](https://github.com/substrate-developer-hub/substrate-parachain-template/) repository.
The parachain template is generated directly at each Polkadot release branch form the [Node Template in Substreate](https://github.com/paritytech/substrate/tree/master/bin/node-template) upstream
A standalone version of this template is available for each release of Polkadot in the [Substrate Developer Hub Parachain Template](https://github.com/substrate-developer-hub/substrate-parachain-template/) repository.
The parachain template is generated directly at each Polkadot release branch from the [Node Template in Substrate](https://github.com/paritytech/substrate/tree/master/bin/node-template) upstream

It is usually best to to use the stand-alone version to start a new project.
It is usually best to use the stand-alone version to start a new project.
All bugs, suggestions, and feature requests should be made upstream in the [Substrate](https://github.com/paritytech/substrate/tree/master/bin/node-template) repository.

## Getting Started
Expand Down Expand Up @@ -158,25 +158,4 @@ To get all the correct dependencies, activate direnv `direnv allow` and lorri `l

### Docker

First, install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/).

Then run the following command to start a single node development chain.

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

This command compiles the code and starts a local development network.
You can also replace the default command (`cargo build --release && ./target/release/node-template --dev --ws-external`) by appending your own.
For example:

```sh
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external

# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev

# Check whether the code is compilable
./scripts/docker_run.sh cargo check
```
Please follow the [Substrate Docker instructions here](https://github.com/paritytech/substrate/blob/master/docker/README.md) to build the Docker container with the Substrate Node Template binary.
17 changes: 0 additions & 17 deletions bin/node-template/docker-compose.yml

This file was deleted.

10 changes: 0 additions & 10 deletions bin/node-template/scripts/docker_run.sh

This file was deleted.

38 changes: 32 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,49 @@ There is no requirement on having Rust or any other toolchain installed but a wo

Unlike the `parity/polkadot` image which contains a single binary (`polkadot`!) used by default, the image in this folder builds and contains several binaries and you need to provide the name of the binary to be called.

You should refer to the .Dockerfile for the actual list. At the time of editing, the list of included binaries is:
You should refer to the [.Dockerfile](./substrate_builder.Dockerfile) for the actual list. At the time of editing, the list of included binaries is:

- substrate
- subkey
- node-template
- chain-spec-builder

To generate the latest parity/substrate image. Please first run:
First, install [Docker](https://docs.docker.com/get-docker/).

Then to generate the latest parity/substrate image. Please run:
```sh
./build.sh
```

> If you wish to create a debug build rather than a production build, then you may modify the [.Dockerfile](./substrate_builder.Dockerfile) replacing `cargo build --locked --release` with just `cargo build --locked` and replacing `target/release` with `target/debug`.
> If you get an error that a tcp port address is already in use then find an available port to use for the host port in the [.Dockerfile](./substrate_builder.Dockerfile).
The image can be used by passing the selected binary followed by the appropriate tags for this binary.

Your best guess to get started is to pass the `--help flag`. Here are a few examples:

- `docker run --rm -it parity/substrate substrate --version`
- `docker run --rm -it parity/substrate subkey --help`
- `docker run --rm -it parity/substrate node-template --version`
- `docker run --rm -it parity/substrate chain-spec-builder --help`
- `./run.sh substrate --version`
- `./run.sh subkey --help`
- `./run.sh node-template --version`
- `./run.sh chain-spec-builder --help`

Then try running the following command to start a single node development chain using the Substrate Node Template binary `node-template`:

```sh
./run.sh node-template --dev --ws-external
```

Note: It is recommended to provide a custom `--base-path` to store the chain database. For example:

```sh
# Run Substrate Node Template without re-compiling
./run.sh node-template --dev --ws-external --base-path=/data
```

> To print logs follow the [Substrate debugging instructions](https://docs.substrate.io/test/debug/).
```sh
# Purge the local dev chain
./run.sh node-template purge-chain --dev --base-path=/data -y
```
13 changes: 13 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

args=$@

# handle when arguments not provided. run arguments provided to script.
if [ "$args" = "" ] ; then
printf "Note: Please try providing an argument to the script.\n\n"
exit 1
else
printf "*** Running Substrate Docker container with provided arguments: $args\n\n"
docker run --rm -it parity/substrate $args
fi

0 comments on commit 77c675b

Please sign in to comment.