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

Commit

Permalink
chore: update builder image (#3884)
Browse files Browse the repository at this point in the history
* chore: update `builder` image

fix #9765

* fix: fix binary path

* chore: refresh of the builder image + build script

* Fix port

* Fix image source

* Update scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile

Co-authored-by: Denis Pisarev <denis.pisarev@parity.io>
  • Loading branch information
chevdor and TriplEight authored Oct 4, 2021
1 parent 1a92391 commit 4870e7b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
8 changes: 3 additions & 5 deletions scripts/dockerfiles/polkadot/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ PROJECT_ROOT=`git rev-parse --show-toplevel`
cd $PROJECT_ROOT

# Find the current version from Cargo.toml
VERSION=`grep "^version" ./Cargo.toml | egrep -o "([0-9\.]+)"`
VERSION=`grep "^version" ./cli/Cargo.toml | egrep -o "([0-9\.]+)"`
GITUSER=parity
GITREPO=polkadot

# Build the image
echo "Building ${GITUSER}/${GITREPO}:latest docker image, hang on!"
time docker build -f ./scripts/docker/polkadot/polkadot_builder.Dockerfile --build-arg RUSTC_WRAPPER= --build-arg PROFILE=release -t ${GITUSER}/${GITREPO}:latest .
time docker build -f ./scripts/dockerfiles/polkadot/polkadot_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}

echo -e "\nIf you just built version ${VERSION}, you may want to update your tag:"
echo " $ docker tag ${GITUSER}/${GITREPO}:$VERSION ${GITUSER}/${GITREPO}:${VERSION}"

popd
30 changes: 17 additions & 13 deletions scripts/dockerfiles/polkadot/docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
version: '3'
services:
node_alice:
build:
context: .
dockerfile: polkadot_builder.Dockerfile
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
image: chevdor/polkadot:latest
- "9615:9615"
image: parity/polkadot:latest
volumes:
- "polkadot-data-alice:/data"
command: polkadot --chain=polkadot-local --alice -d /data --node-key 0000000000000000000000000000000000000000000000000000000000000001
command: |
--chain=polkadot-local
--alice
-d /data
--node-key 0000000000000000000000000000000000000000000000000000000000000001
networks:
testing_net:
ipv4_address: 172.28.1.1

node_bob:
build:
context: .
dockerfile: polkadot_builder.Dockerfile
ports:
- "30344:30344"
- "9935:9935"
- "9945:9945"
image: chevdor/polkadot:latest
- "30344:30333"
- "9935:9933"
- "9945:9944"
- "29615:9615"
image: parity/polkadot:latest
volumes:
- "polkadot-data-bob:/data"
links:
- "node_alice:alice"
command: polkadot --chain=polkadot-local --bob -d /data --port 30344 --rpc-port 9935 --ws-port 9945 --bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR'
command: |
--chain=polkadot-local
--bob
-d /data
--bootnodes '/ip4/172.28.1.1/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR'
networks:
testing_net:
ipv4_address: 172.28.1.2
Expand Down
17 changes: 12 additions & 5 deletions scripts/dockerfiles/polkadot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
version: '3'
services:
polkadot:
build:
context: .
dockerfile: polkadot_builder.Dockerfile
ports:
- "127.0.0.1:30333:30333/tcp"
- "127.0.0.1:9933:9933/tcp"
image: chevdor/polkadot:latest
image: parity/polkadot:latest
volumes:
- "polkadot-data:/data"
command: polkadot
command: |
--unsafe-rpc-external
--unsafe-ws-external
--rpc-cors all
--prometheus-external
ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
- "9615:9615"

volumes:
polkadot-data:
26 changes: 17 additions & 9 deletions scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# This is the build stage for Polkadot. Here we create the binary in a temporary image.
FROM docker.io/paritytech/ci-linux:production as builder
LABEL io.parity.image.description="This is the build stage for Polkadot. Here we create the binary."

WORKDIR /polkadot

COPY . /polkadot

RUN cargo build --release --locked

# ===== SECOND STAGE ======
RUN cargo build --locked --release

# This is the 2nd stage: a very small image where we copy the Polkadot binary."
FROM docker.io/library/ubuntu:20.04
LABEL io.parity.image.description="Polkadot: a platform for web3. This is a self-buit multistage image."

LABEL description="Multistage Docker image for Polkadot: a platform for web3" \
io.parity.image.type="builder" \
io.parity.image.authors="chevdor@gmail.com, devops-team@parity.io" \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.description="Polkadot: a platform for web3" \
io.parity.image.source="https://github.com/paritytech/polkadot/blob/${VCS_REF}/scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile" \
io.parity.image.documentation="https://github.com/paritytech/polkadot/"

COPY --from=builder /polkadot/target/release/polkadot /usr/local/bin

RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \
mkdir -p /polkadot/.local/share && \
mkdir /data && \
mkdir -p /data /polkadot/.local/share && \
chown -R polkadot:polkadot /data && \
ln -s /data /polkadot/.local/share/polkadot && \
rm -rf /usr/bin /usr/sbin
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
/usr/local/bin/polkadot --version

USER polkadot

EXPOSE 30333 9933 9944 9615
VOLUME ["/data"]

Expand Down

0 comments on commit 4870e7b

Please sign in to comment.