Skip to content

Commit 826f16f

Browse files
Add stable-rc tags to the docker images (#5896)
This PR adds the `stableYYMM-rcX` or `stableYYMM-X-rcX` tags to the docker images, so that they could be published with the new tag naming scheme. Closes: paritytech/release-engineering#224
1 parent 261b3da commit 826f16f

File tree

5 files changed

+94
-14
lines changed

5 files changed

+94
-14
lines changed

.github/scripts/common/lib.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ fetch_release_artifacts() {
242242
# - GITHUB_TOKEN
243243
# - REPO in the form paritytech/polkadot
244244
fetch_release_artifacts_from_s3() {
245+
BINARY=$1
245246
echo "Version : $VERSION"
246247
echo "Repo : $REPO"
247248
echo "Binary : $BINARY"
@@ -461,7 +462,7 @@ function get_polkadot_node_version_from_code() {
461462

462463
validate_stable_tag() {
463464
tag="$1"
464-
pattern='^stable[0-9]+(-[0-9]+)?$'
465+
pattern="^stable[0-9]{4}(-[0-9]+)?(-rc[0-9]+)?$"
465466

466467
if [[ $tag =~ $pattern ]]; then
467468
echo $tag

.github/workflows/release-50_publish-docker.yml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686

8787
steps:
8888
- name: Checkout sources
89-
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
89+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
9090

9191
- name: Validate inputs
9292
id: validate_inputs
@@ -111,7 +111,7 @@ jobs:
111111

112112
steps:
113113
- name: Checkout sources
114-
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
114+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
115115

116116
#TODO: this step will be needed when automated triggering will work
117117
#this step runs only if the workflow is triggered automatically when new release is published
@@ -134,7 +134,14 @@ jobs:
134134
. ./.github/scripts/common/lib.sh
135135
136136
VERSION="${{ needs.validate-inputs.outputs.VERSION }}"
137-
fetch_release_artifacts_from_s3
137+
if [[ ${{ inputs.binary }} == 'polkadot' ]]; then
138+
bins=(polkadot polkadot-prepare-worker polkadot-execute-worker)
139+
for bin in "${bins[@]}"; do
140+
fetch_release_artifacts_from_s3 $bin
141+
done
142+
else
143+
fetch_release_artifacts_from_s3 $BINARY
144+
fi
138145
139146
- name: Fetch chain-spec-builder rc artifacts or release artifacts based on release id
140147
#this step runs only if the workflow is triggered manually and only for chain-spec-builder
@@ -159,7 +166,7 @@ jobs:
159166

160167
steps:
161168
- name: Checkout sources
162-
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
169+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
163170

164171
- name: Download artifacts
165172
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
@@ -187,15 +194,14 @@ jobs:
187194
run: |
188195
. ./.github/scripts/common/lib.sh
189196
190-
release="release-${{ needs.validate-inputs.outputs.RELEASE_ID }}" && \
197+
release="${{ needs.validate-inputs.outputs.stable_tag }}" && \
191198
echo "release=${release}" >> $GITHUB_OUTPUT
192199
193200
commit=$(git rev-parse --short HEAD) && \
194201
echo "commit=${commit}" >> $GITHUB_OUTPUT
195202
196-
tag=$(git name-rev --tags --name-only $(git rev-parse HEAD)) && \
197-
[ "${tag}" != "undefined" ] && echo "tag=${tag}" >> $GITHUB_OUTPUT || \
198-
echo "No tag, doing without"
203+
tag="${{ needs.validate-inputs.outputs.version }}" && \
204+
echo "tag=${tag}" >> $GITHUB_OUTPUT
199205
200206
- name: Fetch release tags
201207
working-directory: release-artifacts
@@ -215,8 +221,20 @@ jobs:
215221
echo "release=${release}" >> $GITHUB_OUTPUT
216222
echo "stable=${{ needs.validate-inputs.outputs.stable_tag }}" >> $GITHUB_OUTPUT
217223
218-
- name: Build Injected Container image for polkadot rc or chain-spec-builder
219-
if: ${{ env.BINARY == 'polkadot' || env.BINARY == 'chain-spec-builder' }}
224+
- name: Build Injected Container image for polkadot rc
225+
if: ${{ env.BINARY == 'polkadot' }}
226+
env:
227+
ARTIFACTS_FOLDER: release-artifacts
228+
IMAGE_NAME: ${{ env.BINARY }}
229+
OWNER: ${{ env.DOCKER_OWNER }}
230+
TAGS: ${{ join(steps.fetch_rc_refs.outputs.*, ',') || join(steps.fetch_release_refs.outputs.*, ',') }}
231+
run: |
232+
ls -al
233+
echo "Building container for $BINARY"
234+
./docker/scripts/polkadot/build-injected.sh $ARTIFACTS_FOLDER
235+
236+
- name: Build Injected Container image chain-spec-builder
237+
if: ${{ env.BINARY == 'chain-spec-builder' }}
220238
env:
221239
ARTIFACTS_FOLDER: release-artifacts
222240
IMAGE_NAME: ${{ env.BINARY }}
@@ -243,7 +261,15 @@ jobs:
243261
echo "Building container for $BINARY"
244262
./docker/scripts/build-injected.sh
245263
246-
- name: Login to Dockerhub
264+
- name: Login to Dockerhub to publish polkadot
265+
if: ${{ env.BINARY == 'polkadot' }}
266+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
267+
with:
268+
username: ${{ secrets.POLKADOT_DOCKERHUB_USERNAME }}
269+
password: ${{ secrets.POLKADOT_DOCKERHUB_TOKEN }}
270+
271+
- name: Login to Dockerhub to puiblish polkadot-parachain/chain-spec-builder
272+
if: ${{ env.BINARY == 'polkadot-parachain' || env.BINARY == 'chain-spec-builder' }}
247273
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
248274
with:
249275
username: ${{ secrets.CUMULUS_DOCKERHUB_USERNAME }}
@@ -295,7 +321,7 @@ jobs:
295321
environment: release
296322
steps:
297323
- name: Checkout sources
298-
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
324+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
299325

300326
- name: Set up Docker Buildx
301327
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM docker.io/parity/base-bin
2+
3+
# metadata
4+
ARG VCS_REF
5+
ARG BUILD_DATE
6+
ARG IMAGE_NAME
7+
# That can be a single one or a comma separated list
8+
ARG BINARY=polkadot
9+
10+
LABEL io.parity.image.authors="[email protected]" \
11+
io.parity.image.vendor="Parity Technologies" \
12+
io.parity.image.title="parity/polkadot" \
13+
io.parity.image.description="Polkadot: a platform for web3. This is the official Parity image with an injected binary." \
14+
io.parity.image.source="https://github.com/paritytech/polkadot-sdk/blob/${VCS_REF}/docker/dockerfiles/polkadot/polkadot_injected.Dockerfile" \
15+
io.parity.image.revision="${VCS_REF}" \
16+
io.parity.image.created="${BUILD_DATE}" \
17+
io.parity.image.documentation="https://github.com/paritytech/polkadot-sdk/"
18+
19+
# show backtraces
20+
ENV RUST_BACKTRACE 1
21+
22+
USER root
23+
WORKDIR /app
24+
25+
# add polkadot and polkadot-*-worker binaries to the docker image
26+
COPY bin/* /usr/local/bin/
27+
COPY entrypoint.sh .
28+
29+
30+
RUN chmod -R a+rx "/usr/local/bin"; \
31+
mkdir -p /data /polkadot/.local/share && \
32+
chown -R parity:parity /data && \
33+
ln -s /data /polkadot/.local/share/polkadot
34+
35+
USER parity
36+
37+
# check if executable works in this container
38+
RUN /usr/local/bin/polkadot --version
39+
RUN /usr/local/bin/polkadot-prepare-worker --version
40+
RUN /usr/local/bin/polkadot-execute-worker --version
41+
42+
43+
EXPOSE 30333 9933 9944 9615
44+
VOLUME ["/polkadot"]
45+
46+
ENV BINARY=${BINARY}
47+
48+
# ENTRYPOINT
49+
ENTRYPOINT ["/app/entrypoint.sh"]
50+
51+
# We call the help by default
52+
CMD ["--help"]

docker/scripts/build-injected.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ VCS_REF=${VCS_REF:-01234567}
4040
echo "Using engine: $ENGINE"
4141
echo "Using Dockerfile: $DOCKERFILE"
4242
echo "Using context: $CONTEXT"
43-
echo "Building ${IMAGE}:latest container image for ${BINARY} v${VERSION} from ${ARTIFACTS_FOLDER} hang on!"
43+
echo "Building ${IMAGE}:latest container image for ${BINARY} ${VERSION} from ${ARTIFACTS_FOLDER} hang on!"
4444
echo "ARTIFACTS_FOLDER=$ARTIFACTS_FOLDER"
4545
echo "CONTEXT=$CONTEXT"
4646

docker/scripts/polkadot/build-injected.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ PROJECT_ROOT=`git rev-parse --show-toplevel`
99

1010
export BINARY=polkadot,polkadot-execute-worker,polkadot-prepare-worker
1111
export ARTIFACTS_FOLDER=$1
12+
export DOCKERFILE="docker/dockerfiles/polkadot/polkadot_injected.Dockerfile"
1213

1314
$PROJECT_ROOT/docker/scripts/build-injected.sh

0 commit comments

Comments
 (0)