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

chore: update builder image #3884

Merged
merged 9 commits into from
Oct 4, 2021
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
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
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
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'
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
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
TriplEight marked this conversation as resolved.
Show resolved Hide resolved

ports:
- "30333:30333"
- "9933:9933"
- "9944:9944"
- "9615:9615"

volumes:
polkadot-data:
28 changes: 18 additions & 10 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
ln -s /data /polkadot/.local/share/polkadot

# check if executable works in this container
RUN /usr/local/bin/polkadot --version

RUN rm -rf /usr/bin /usr/sbin
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
USER polkadot

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

Expand Down