diff --git a/scripts/dockerfiles/polkadot/build.sh b/scripts/dockerfiles/polkadot/build.sh index ee4d29991a86..cf100bedbfaa 100755 --- a/scripts/dockerfiles/polkadot/build.sh +++ b/scripts/dockerfiles/polkadot/build.sh @@ -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 diff --git a/scripts/dockerfiles/polkadot/docker-compose-local.yml b/scripts/dockerfiles/polkadot/docker-compose-local.yml index 2c93799259ef..1ff3a1ccaac2 100644 --- a/scripts/dockerfiles/polkadot/docker-compose-local.yml +++ b/scripts/dockerfiles/polkadot/docker-compose-local.yml @@ -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 diff --git a/scripts/dockerfiles/polkadot/docker-compose.yml b/scripts/dockerfiles/polkadot/docker-compose.yml index 54fe158735d8..978191af88c1 100644 --- a/scripts/dockerfiles/polkadot/docker-compose.yml +++ b/scripts/dockerfiles/polkadot/docker-compose.yml @@ -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: diff --git a/scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile b/scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile index 2fc5787e6cb0..6b096244a506 100644 --- a/scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile +++ b/scripts/dockerfiles/polkadot/polkadot_builder.Dockerfile @@ -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"]