From fbdf49dbf8bf82b889f2c0a54abe0561b4916f59 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 14 Oct 2021 19:10:39 +0200 Subject: [PATCH 1/2] archive dockerfile --- docker/Dockerfile | 28 ++++++++++++++++++++++++++++ docker/build.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/build.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..f7cacf38 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +FROM docker.io/paritytech/ci-linux:production as builder +LABEL description="build stage for Substrate Archive. We are creating the binary." + +ARG PROFILE=release +WORKDIR /bin/polkadot-archive/ + +COPY . /bin/polkadot-archive/ + +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 /bin/polkadot-archive/target/$PROFILE/polkadot-archive /usr/local/bin + +RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot-archive polkadot-archive && \ + mkdir -p /polkadot-archive/.local/share && \ + mkdir /data && \ + chown -R polkadot-archive:polkadot-archive /data && \ + ln -s /data /polkadot-archive/.local/share/polkadot-archive && \ + rm -rf /usr/bin /usr/sbin + +USER polkadot-archive +VOLUME ["/data"] + +CMD ["/usr/local/bin/polkadot-archive"] diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 00000000..d52e68fb --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + +pushd . + +# The following line ensure we run from the project root +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\.]+)"` +GITUSER=parity +GITREPO=substrate-archive + +# 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 . + +# 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 From 91c70929c7667efc11815f7510a4d0b1fa502278 Mon Sep 17 00:00:00 2001 From: rafael Date: Mon, 7 Feb 2022 11:56:10 +0100 Subject: [PATCH 2/2] updated to insipx latest, using debian buster for second stage, installing missing libssl --- docker/Dockerfile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f7cacf38..fd8387d6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,18 +2,25 @@ FROM docker.io/paritytech/ci-linux:production as builder LABEL description="build stage for Substrate Archive. We are creating the binary." ARG PROFILE=release -WORKDIR /bin/polkadot-archive/ +WORKDIR /substrate-archive -COPY . /bin/polkadot-archive/ +COPY . /substrate-archive -RUN cargo build --$PROFILE +RUN cargo build --$PROFILE --bin polkadot-archive +RUN ls # ===== SECOND STAGE ====== -FROM docker.io/library/ubuntu:20.04 +FROM docker.io/library/debian:buster LABEL description="This is the 2nd stage: a very small image where we copy the Polkadot binary." ARG PROFILE=release -COPY --from=builder /bin/polkadot-archive/target/$PROFILE/polkadot-archive /usr/local/bin +RUN ls +COPY --from=builder /substrate-archive/target/$PROFILE/polkadot-archive /usr/local/bin + +RUN apt-get update && \ + apt-get install -y libssl1.1 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot-archive polkadot-archive && \ mkdir -p /polkadot-archive/.local/share && \ @@ -26,3 +33,4 @@ USER polkadot-archive VOLUME ["/data"] CMD ["/usr/local/bin/polkadot-archive"] +