From 2e058104e3d3a9df5be004edccd25a02595ecf03 Mon Sep 17 00:00:00 2001 From: Luke Schoen Date: Thu, 9 Mar 2023 00:57:44 +1100 Subject: [PATCH] Update Docker instructions (#13437) --- .gitignore | 1 + README.md | 1 + bin/node-template/README.md | 29 +++---------------- bin/node-template/docker-compose.yml | 17 ----------- bin/node-template/scripts/docker_run.sh | 10 ------- docker/README.md | 38 +++++++++++++++++++++---- docker/run.sh | 13 +++++++++ 7 files changed, 51 insertions(+), 58 deletions(-) delete mode 100644 bin/node-template/docker-compose.yml delete mode 100755 bin/node-template/scripts/docker_run.sh create mode 100755 docker/run.sh diff --git a/.gitignore b/.gitignore index efb63520e1e1b..f30103c625fe0 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ rls*.log *.bin *.iml scripts/ci/node-template-release/Cargo.lock +bin/node-template/Cargo.lock substrate.code-workspace diff --git a/README.md b/README.md index 7d8c7e575581c..361f410ab2790 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/node-template/README.md b/bin/node-template/README.md index c42b58449565d..7562b6247f353 100644 --- a/bin/node-template/README.md +++ b/bin/node-template/README.md @@ -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 @@ -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. diff --git a/bin/node-template/docker-compose.yml b/bin/node-template/docker-compose.yml deleted file mode 100644 index bc1922f47d963..0000000000000 --- a/bin/node-template/docker-compose.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "3.2" - -services: - dev: - container_name: node-template - image: paritytech/ci-linux:production - 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" diff --git a/bin/node-template/scripts/docker_run.sh b/bin/node-template/scripts/docker_run.sh deleted file mode 100755 index 0bac44b4cfb3b..0000000000000 --- a/bin/node-template/scripts/docker_run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# This script is meant to be run on Unix/Linux based systems -set -e - -echo "*** Start Substrate node template ***" - -cd $(dirname ${BASH_SOURCE[0]})/.. - -docker-compose down --remove-orphans -docker-compose run --rm --service-ports dev $@ diff --git a/docker/README.md b/docker/README.md index b3b80678797a4..71ddb2dffd1bb 100644 --- a/docker/README.md +++ b/docker/README.md @@ -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 +``` diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 0000000000000..43510bee07f58 --- /dev/null +++ b/docker/run.sh @@ -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 +