Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

feat: Update primary Substrate Docker instructions. Remove and redirect legacy erroneous substrate-node-template Docker instructions #13437

Merged
merged 11 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ rls*.log
*.bin
*.iml
scripts/ci/node-template-release/Cargo.lock
bin/node-template/Cargo.lock
dmitry-markin marked this conversation as resolved.
Show resolved Hide resolved
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
8 changes: 8 additions & 0 deletions bin/node-template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

Copy link
Contributor Author

@ltfschoen ltfschoen Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've removed that file now.
i checked it still builds successfully when i ran the following on ubuntu 22.04 LTS after removing that file:

cd bin/node-template && \
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y && \
. $HOME/.cargo/env && \
sudo apt install -y build-essential libclang-dev protobuf-compiler && \
rustup update nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly && \
cargo build --release

members = [
"node",
"pallets/template",
"runtime",
]
[profile.release]
panic = "unwind"
27 changes: 3 additions & 24 deletions bin/node-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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.
ltfschoen marked this conversation as resolved.
Show resolved Hide resolved
The parachain template is generated directly at each Polkadot release branch form the [Node Template in Substrate](https://github.com/paritytech/substrate/tree/master/bin/node-template) upstream
ltfschoen marked this conversation as resolved.
Show resolved Hide resolved

It is usually best to to use the stand-alone version to start a new project.
ltfschoen marked this conversation as resolved.
Show resolved Hide resolved
All bugs, suggestions, and feature requests should be made upstream in the [Substrate](https://github.com/paritytech/substrate/tree/master/bin/node-template) repository.
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.

43 changes: 37 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
# Substrate Builder Docker Image

The Docker image in this folder is a `builder` image. It is self contained and allow users to build the binaries themselves.
The Docker image in this folder is a `builder` image. It is self contained and allows users to build the binaries themselves.
There is no requirement on having Rust or any other toolchain installed but a working Docker environment.

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

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

4 changes: 2 additions & 2 deletions docker/substrate_builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ RUN useradd -m -u 1000 -U -s /bin/sh -d /substrate substrate && \
mkdir -p /data /substrate/.local/share/substrate && \
chown -R substrate:substrate /data && \
ln -s /data /substrate/.local/share/substrate && \
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# Sanity checks
ldd /usr/local/bin/substrate && \
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
/usr/local/bin/substrate --version

USER substrate
Expand Down