diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index e068ec086f2f..000000000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM docker.io/paritytech/ci-linux:production as builder -LABEL description="This is the build stage for Polkadot. Here we create the binary." - -ARG PROFILE=release -WORKDIR /polkadot - -COPY . /polkadot - -RUN cargo build --$PROFILE - -# ===== SECOND STAGE ====== - -FROM docker.io/library/ubuntu:20.04 -LABEL description="This is the 2nd stage: a very small image where we copy the Polkadot binary." -ARG PROFILE=release -COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin - -RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \ - mkdir -p /polkadot/.local/share && \ - mkdir /data && \ - chown -R polkadot:polkadot /data && \ - ln -s /data /polkadot/.local/share/polkadot && \ - rm -rf /usr/bin /usr/sbin - -USER polkadot -EXPOSE 30333 9933 9944 -VOLUME ["/data"] - -CMD ["/usr/local/bin/polkadot"] diff --git a/docker/build.sh b/docker/build.sh index 6456383fcdea..523ce325d71f 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -14,7 +14,8 @@ GITREPO=polkadot # Build the image echo "Building ${GITUSER}/${GITREPO}:latest docker image, hang on!" -time docker build -f ./docker/Dockerfile --build-arg RUSTC_WRAPPER= --build-arg PROFILE=release -t ${GITUSER}/${GITREPO}:latest . +DOCKERFILE=./docker/polkadot_builder.Dockerfile +time docker build -f $DOCKERFILE --build-arg RUSTC_WRAPPER= --build-arg PROFILE=release -t ${GITUSER}/${GITREPO}:latest . # Show the list of available images for this repo echo "Image is ready" diff --git a/docker/docker-compose-local.yml b/docker/docker-compose-local.yml index 079d73825227..cdfc175deda8 100644 --- a/docker/docker-compose-local.yml +++ b/docker/docker-compose-local.yml @@ -7,6 +7,7 @@ services: - "30333:30333" - "9933:9933" - "9944:9944" + - "9615:9615" image: chevdor/polkadot:latest volumes: - "polkadot-data-alice:/data" @@ -22,6 +23,7 @@ services: - "30344:30344" - "9935:9935" - "9945:9945" + - "9615:9615" image: chevdor/polkadot:latest volumes: - "polkadot-data-bob:/data" diff --git a/docker/polkadot_builder.Dockerfile b/docker/polkadot_builder.Dockerfile new file mode 100644 index 000000000000..5ad61ac64c9f --- /dev/null +++ b/docker/polkadot_builder.Dockerfile @@ -0,0 +1,42 @@ +# 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 + +ARG PROFILE=release + +WORKDIR /polkadot + +COPY . /polkadot + +RUN cargo build --locked --$PROFILE + + +# This is the 2nd stage: a very small image where we copy the Polkadot binary." +FROM docker.io/library/ubuntu:20.04 + +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}/docker/Dockerfile" \ + io.parity.image.documentation="https://github.com/paritytech/polkadot/" + +ARG PROFILE=release + +COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin + +RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \ + mkdir -p /data /polkadot/.local/share && \ + chown -R polkadot:polkadot /data && \ + ln -s /data /polkadot/.local/share/polkadot && \ + rm -rf /usr/bin /usr/sbin + +USER polkadot + +# check if executable works in this container +RUN /usr/bin/polkadot --version + +EXPOSE 30333 9933 9944 9615 +VOLUME ["/polkadot"] + +ENTRYPOINT ["/usr/local/bin/polkadot"]