This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refresh of the substrate_builder image (#9808)
* chore: refresh of the substrate_builder image fix #9715 * chore: renaming + build script * Fix spaces/tabs * Add doc * Remove non binary * Update docker/substrate_builder.Dockerfile Co-authored-by: Denis Pisarev <[email protected]>
- Loading branch information
1 parent
125092f
commit ddc2c6e
Showing
5 changed files
with
82 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ doc | |
Dockerfile | ||
.dockerignore | ||
.local | ||
.env* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
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: | ||
|
||
- substrate | ||
- subkey | ||
- node-template | ||
- chain-spec-builder | ||
|
||
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
pushd . | ||
|
||
# The following line ensure we run from the project root | ||
PROJECT_ROOT=`git rev-parse --show-toplevel` | ||
cd $PROJECT_ROOT | ||
|
||
# Find the current version from Cargo.toml | ||
VERSION=`grep "^version" ./bin/node/cli/Cargo.toml | egrep -o "([0-9\.]+)"` | ||
GITUSER=parity | ||
GITREPO=substrate | ||
|
||
# Build the image | ||
echo "Building ${GITUSER}/${GITREPO}:latest docker image, hang on!" | ||
time docker build -f ./docker/substrate_builder.Dockerfile -t ${GITUSER}/${GITREPO}:latest . | ||
docker tag ${GITUSER}/${GITREPO}:latest ${GITUSER}/${GITREPO}:v${VERSION} | ||
|
||
# Show the list of available images for this repo | ||
echo "Image is ready" | ||
docker images | grep ${GITREPO} | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This is the build stage for Substrate. Here we create the binary. | ||
FROM docker.io/paritytech/ci-linux:production as builder | ||
|
||
WORKDIR /substrate | ||
COPY . /substrate | ||
RUN cargo build --locked --release | ||
|
||
# This is the 2nd stage: a very small image where we copy the Substrate binary." | ||
FROM docker.io/library/ubuntu:20.04 | ||
LABEL description="Multistage Docker image for Substrate: a platform for web3" \ | ||
io.parity.image.type="builder" \ | ||
io.parity.image.authors="[email protected], [email protected]" \ | ||
io.parity.image.vendor="Parity Technologies" \ | ||
io.parity.image.description="Substrate is a next-generation framework for blockchain innovation 🚀" \ | ||
io.parity.image.source="https://github.com/paritytech/polkadot/blob/${VCS_REF}/docker/substrate_builder.Dockerfile" \ | ||
io.parity.image.documentation="https://github.com/paritytech/polkadot/" | ||
|
||
COPY --from=builder /substrate/target/release/substrate /usr/local/bin | ||
COPY --from=builder /substrate/target/release/subkey /usr/local/bin | ||
COPY --from=builder /substrate/target/release/node-template /usr/local/bin | ||
COPY --from=builder /substrate/target/release/chain-spec-builder /usr/local/bin | ||
|
||
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 && \ | ||
/usr/local/bin/substrate --version | ||
|
||
USER substrate | ||
EXPOSE 30333 9933 9944 9615 | ||
VOLUME ["/data"] |