diff --git a/.dockerignore b/.dockerignore index b60de5b..da6a8f2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ -**/target +target/ +Dockerfile +.dockerignore diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index ca7d3b6..49fbb87 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -28,3 +28,6 @@ jobs: - name: Build the docker image run: docker build . -t polkadot-sdk-minimal-template + + - name: Try running the container + run: docker run --rm polkadot-sdk-minimal-template --help diff --git a/Dockerfile b/Dockerfile index 463479f..0c59192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,28 @@ -# This is the build stage for Polkadot. Here we create the binary in a temporary image. FROM docker.io/paritytech/ci-unified:latest as builder WORKDIR /polkadot COPY . /polkadot +RUN cargo fetch RUN cargo build --locked --release -# This is the 2nd stage: a very small image where we copy the Polkadot binary." FROM docker.io/parity/base-bin:latest -LABEL description="Multistage Docker image for Polkadot: a platform for web3" +COPY --from=builder /polkadot/target/release/minimal-template-node /usr/local/bin -COPY --from=builder /polkadot/target/release/polkadot /usr/local/bin - -RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \ +USER root +RUN useradd -m -u 1001 -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 && \ # unclutter and minimize the attack surface rm -rf /usr/bin /usr/sbin && \ # check if executable works in this container - /usr/local/bin/polkadot --version + /usr/local/bin/minimal-template-node --version USER polkadot EXPOSE 30333 9933 9944 9615 VOLUME ["/data"] -ENTRYPOINT ["/usr/local/bin/polkadot"] +ENTRYPOINT ["/usr/local/bin/minimal-template-node"]