-
Notifications
You must be signed in to change notification settings - Fork 18
232 lines (203 loc) · 8.33 KB
/
Copy pathnode_docker_build.yml
File metadata and controls
232 lines (203 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: "Catalyst Node - Docker build and push"
on:
workflow_dispatch:
push:
branches: [master]
tags:
- "v*"
paths:
- "common/**"
- "e2e_tests/**"
- "pacaya/**"
- "permissionless/**"
- "node/**"
- "shasta/**"
- "urc/**"
env:
DOCKER_PUBLIC_REGISTRY: docker.io
DOCKER_PUBLIC_REPOSITORY: nethermind/catalyst-node
DOCKER_REGISTRY: nethermind.jfrog.io
DOCKER_REPOSITORY_STAGING: core-oci-local-staging/catalyst-node
MASTER_BRANCH: refs/heads/master
jobs:
build:
name: Build per-arch image
runs-on: ${{ matrix.os }}
if: github.repository == 'NethermindEth/Catalyst'
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux/amd64
short: amd64
- os: ubuntu-24.04-arm
platform: linux/arm64
short: arm64
outputs:
digest-amd64: ${{ steps.digest.outputs.amd64 }}
digest-arm64: ${{ steps.digest.outputs.arm64 }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to JFrog Artifactory
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.ARTIFACTORY_CORE_USERNAME }}
password: ${{ secrets.ARTIFACTORY_CORE_TOKEN_DEVELOPER }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: ${{ matrix.platform }}
push: true
build-args: |
BLST_PORTABLE=1
outputs: type=image,name=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_STAGING }},push-by-digest=true,name-canonical=true
- name: Set digest output
id: digest
run: |
echo "${{ matrix.short }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
merge:
name: Merge and push multi-arch manifest
runs-on: ubuntu-latest
needs: build
steps:
- name: Login to JFrog Artifactory
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.ARTIFACTORY_CORE_USERNAME }}
password: ${{ secrets.ARTIFACTORY_CORE_TOKEN_DEVELOPER }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Calculate SHA tag
id: sha
run: |
SHORT_SHA="${{ github.sha }}"
SHORT_SHA=${SHORT_SHA:0:7}
echo "tag=sha-${SHORT_SHA}" >> $GITHUB_OUTPUT
echo "short=${SHORT_SHA}" >> $GITHUB_OUTPUT
- name: Determine tags and event type
id: tags
run: |
REF="${{ github.ref }}"
SHA_TAG="sha-${{ steps.sha.outputs.short }}"
SOURCE_PROMOTE_TAG="${{ steps.sha.outputs.tag }}"
IS_MASTER=false
IS_TAG=false
VERSION_TAG=""
PROMOTE_TAGS="$SHA_TAG"
if [[ "$REF" == refs/tags/* ]]; then
IS_TAG=true
VERSION_TAG=${REF#refs/tags/}
echo "tag_list=type=raw,value=$VERSION_TAG" >> $GITHUB_OUTPUT
PROMOTE_TAGS="$SHA_TAG $VERSION_TAG"
elif [[ "$REF" == ${{ env.MASTER_BRANCH }} ]]; then
IS_MASTER=true
echo "tag_list=type=raw,value=latest" >> $GITHUB_OUTPUT
PROMOTE_TAGS="$SHA_TAG latest"
else
echo "tag_list=type=sha,value=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
# Staging gets the SHA tag plus whatever the conditional ref produced.
STAGING_TAGS="$PROMOTE_TAGS"
echo "is_master=$IS_MASTER" >> $GITHUB_OUTPUT
echo "is_tag=$IS_TAG" >> $GITHUB_OUTPUT
echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
echo "source_promote_tag=$SOURCE_PROMOTE_TAG" >> $GITHUB_OUTPUT
echo "promote_tags=$PROMOTE_TAGS" >> $GITHUB_OUTPUT
echo "staging_tags=$STAGING_TAGS" >> $GITHUB_OUTPUT
echo "PROMOTE_TAGS=$PROMOTE_TAGS" >> $GITHUB_ENV
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_STAGING }}
tags: ${{ steps.tags.outputs.tag_list }}
- name: Create and push manifest list
run: |
# Filter out "latest" tag if not on master branch
if [[ "${{ steps.tags.outputs.is_master }}" != "true" ]]; then
FILTERED_TAGS=$(jq -cr '.tags | map(select(. | endswith(":latest") | not)) | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
else
FILTERED_TAGS=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
fi
if [ -n "$FILTERED_TAGS" ]; then
docker buildx imagetools create \
$FILTERED_TAGS \
${{ needs.build.outputs.digest-amd64 }} \
${{ needs.build.outputs.digest-arm64 }}
fi
- name: Tag with commit SHA
run: |
docker buildx imagetools create \
-t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_STAGING }}:${{ steps.sha.outputs.tag }} \
${{ needs.build.outputs.digest-amd64 }} \
${{ needs.build.outputs.digest-arm64 }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_PUBLIC_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Promote to Docker Hub Production
id: promote
env:
SOURCE_TAG: ${{ steps.tags.outputs.source_promote_tag }}
run: |
set -euo pipefail
source_image="${DOCKER_REGISTRY}/${DOCKER_REPOSITORY_STAGING}:${SOURCE_TAG}"
echo "Tags to promote: $PROMOTE_TAGS"
: > subject.checksums.txt
for tag in $PROMOTE_TAGS; do
target_image="${DOCKER_PUBLIC_REGISTRY}/${DOCKER_PUBLIC_REPOSITORY}:${tag}"
echo ""
echo "=== Promoting ${source_image} -> ${target_image} ==="
# Copy the full multi-arch manifest list registry-to-registry.
# A plain docker pull/tag/push would flatten the index to the
# runner's architecture (amd64) and silently drop the arm64 image.
docker buildx imagetools create -t "${target_image}" "${source_image}"
# Record the promoted manifest digest for provenance/attestation.
DIGEST=$(docker buildx imagetools inspect "${target_image}" --raw | sha256sum | cut -d' ' -f1)
echo "${DIGEST} ${target_image}" >> subject.checksums.txt
echo "✓ Promoted ${tag} (sha256:${DIGEST})"
done
echo ""
echo "All tags promoted successfully"
echo "--- subject.checksums.txt ---"
cat subject.checksums.txt
- name: Summary
run: |
STAGING_REPO="${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY_STAGING }}"
PROD_REPO="${{ env.DOCKER_PUBLIC_REGISTRY }}/${{ env.DOCKER_PUBLIC_REPOSITORY }}"
STAGING_TAGS="${{ steps.tags.outputs.staging_tags }}"
PROMOTE_TAGS_OUT="${{ steps.tags.outputs.promote_tags }}"
echo "## Catalyst Node Docker build Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: \`${{ github.sha }}\` (\`${{ steps.sha.outputs.short }}\`)" >> $GITHUB_STEP_SUMMARY
echo "- **Platforms**: linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Staging — \`${STAGING_REPO}\`" >> $GITHUB_STEP_SUMMARY
if [ -n "$STAGING_TAGS" ]; then
for tag in $STAGING_TAGS; do
echo "- \`${STAGING_REPO}:${tag}\`" >> $GITHUB_STEP_SUMMARY
done
else
echo "- _No tags pushed_" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Production — \`${PROD_REPO}\`" >> $GITHUB_STEP_SUMMARY
if [ -n "$PROMOTE_TAGS_OUT" ]; then
for tag in $PROMOTE_TAGS_OUT; do
echo "- \`${PROD_REPO}:${tag}\`" >> $GITHUB_STEP_SUMMARY
done
else
echo "- _No tags promoted_" >> $GITHUB_STEP_SUMMARY
fi