-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[CI] Docker image updates #1799
Changes from 14 commits
bf45bc9
6a2a9c6
a17194a
ba3b263
5978f93
82c6f5a
2b0cc58
73ebf00
082b7de
62486ed
203aaee
75ea3a2
7ca38df
f7ca643
1fe9d5a
2280979
e9e3025
2ec01fa
59aa24c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Publish Docker image for new releases | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Dockerhub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
file: scripts/docker/Dockerfile.release | ||
tags: | | ||
parity/polkadot:latest | ||
parity/polkadot:${{ github.event.release.tag_name }} | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,21 @@ | ||
FROM phusion/baseimage:0.11 as builder | ||
LABEL maintainer "chevdor@gmail.com" | ||
FROM 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 apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y cmake pkg-config libssl-dev git clang | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ | ||
export PATH=$PATH:$HOME/.cargo/bin && \ | ||
scripts/init.sh && \ | ||
cargo build --$PROFILE | ||
RUN cargo build --$PROFILE | ||
|
||
# ===== SECOND STAGE ====== | ||
|
||
FROM phusion/baseimage:0.11 | ||
LABEL maintainer "chevdor@gmail.com" | ||
FROM debian:buster-slim | ||
LABEL description="This is the 2nd stage: a very small image where we copy the Polkadot binary." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use the same Label as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intention of this Dockerfile is to be used by users - i.e., for dev purposes etc., so it doesn't make sense to have vendor info and references to variables (like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OCI recommends filling labels as a best practice. At least it can be handy to know where is the code of this Dockerfile, this could be in label. |
||
ARG PROFILE=release | ||
COPY --from=builder /polkadot/target/$PROFILE/polkadot /usr/local/bin | ||
|
||
RUN mv /usr/share/ca* /tmp && \ | ||
rm -rf /usr/share/* && \ | ||
mv /tmp/ca-certificates /usr/share/ && \ | ||
rm -rf /usr/lib/python* && \ | ||
useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \ | ||
RUN useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \ | ||
mkdir -p /polkadot/.local/share/polkadot && \ | ||
chown -R polkadot:polkadot /polkadot/.local && \ | ||
ln -s /polkadot/.local/share/polkadot /data && \ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||
FROM debian:buster-slim | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's better to use "Dockerfile" as an extension: |
||||||
|
||||||
# metadata | ||||||
ARG VCS_REF | ||||||
ARG BUILD_DATE | ||||||
|
||||||
LABEL io.parity.image.authors="devops-team@parity.io" \ | ||||||
io.parity.image.vendor="Parity Technologies" \ | ||||||
io.parity.image.title="parity/polkadot" \ | ||||||
io.parity.image.description="polkadot: a platform for web3" \ | ||||||
io.parity.image.source="https://github.com/paritytech/polkadot/blob/${VCS_REF}/scripts/docker/Dockerfile" \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
io.parity.image.revision="${VCS_REF}" \ | ||||||
io.parity.image.created="${BUILD_DATE}" \ | ||||||
io.parity.image.documentation="https://github.com/paritytech/polkadot/" | ||||||
|
||||||
# show backtraces | ||||||
ENV RUST_BACKTRACE 1 | ||||||
|
||||||
# install tools and dependencies | ||||||
RUN apt-get update && \ | ||||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \ | ||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||||||
libssl1.1 \ | ||||||
ca-certificates \ | ||||||
curl \ | ||||||
gnupg && \ | ||||||
gpg --recv-keys --keyserver hkps://keys.mailvelope.com 9D4B2B6EB8F97156D19669A9FF0812D491B96798 && \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation here and below |
||||||
gpg --export 9D4B2B6EB8F97156D19669A9FF0812D491B96798 > /usr/share/keyrings/parity.gpg && \ | ||||||
echo 'deb [signed-by=/usr/share/keyrings/parity.gpg] https://releases.parity.io/deb release main' > /etc/apt/sources.list.d/parity.list && \ | ||||||
apt update && \ | ||||||
apt install polkadot && \ | ||||||
# apt cleanup | ||||||
apt-get autoremove -y && \ | ||||||
apt-get clean && \ | ||||||
find /var/lib/apt/lists/ -type f -not -name lock -delete | ||||||
|
||||||
USER polkadot | ||||||
|
||||||
# check if executable works in this container | ||||||
RUN /usr/bin/polkadot --version | ||||||
|
||||||
EXPOSE 30333 9933 9944 | ||||||
VOLUME ["/polkadot"] | ||||||
|
||||||
ENTRYPOINT ["/usr/bin/polkadot"] | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also I have some questions on
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As per our README.md, I only claim our packages support the latest release versions of debian + ubuntu. It won't work with debian stretch - this is actually because the image used to build our release bins is base-ci-linux, which is based on buster also.
This dockerfile installs polkadot from our apt repository, so it gets placed in
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
oh, then we should change the base for the other image. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's worth mentioning in the comment there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually cache layers in docker builds with Buildx, which gives a significant performance boost here.
First you'd need to set up caching, with a separate step (prior
build-push-action
):And then in your
build-push-action
itself you just addproperties, and everything seems to work. (At least on that silly side-project of mine.)