Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: rvalle/feature docker #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 /substrate-archive

COPY . /substrate-archive

RUN cargo build --$PROFILE --bin polkadot-archive
RUN ls

# ===== SECOND STAGE ======

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
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 && \
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"]

26 changes: 26 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -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\.]+)"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if it's just me, but I have to change this to /bin/polkadot-archive/Cargo.toml to work -- there's no version in the root Cargo.toml since it's a workspace,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Yes, I noticed it failing to collect any version.

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