Skip to content

Commit d06c970

Browse files
test docker
1 parent f30c61d commit d06c970

File tree

7 files changed

+352
-159
lines changed

7 files changed

+352
-159
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Test Docker Images
2+
3+
#on:
4+
# pull_request:
5+
6+
jobs:
7+
8+
build-images:
9+
name: Core docker images
10+
secrets: inherit
11+
strategy:
12+
matrix:
13+
component:
14+
- server-v2
15+
# - external-node
16+
# - snapshots-creator
17+
uses: matter-labs/zksync-era/.github/workflows/REUSED_build-docker-common.yaml@aba-ci-optimize
18+
with:
19+
image: ${{ matrix.component }}
20+
dockerfile: docker/${{ matrix.component }}/Dockerfile
21+
22+
23+
# build-images:
24+
# name: Build and Push Docker Images
25+
# env:
26+
# IMAGE_TAG_SUFFIX: ${{ inputs.image_tag_suffix }}${{ (inputs.en_alpha_release && matrix.components == 'external-node') && '-alpha' || '' }}
27+
# runs-on: ${{ fromJSON('["matterlabs-ci-runner-high-performance", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }}
28+
# permissions:
29+
# packages: write
30+
# contents: read
31+
# strategy:
32+
# matrix:
33+
# components:
34+
# - server-v2
35+
# - external-node
36+
# - snapshots-creator
37+
# platforms:
38+
# - linux/amd64
39+
# include:
40+
# - components: external-node
41+
# platforms: linux/arm64
42+
#
43+
# steps:
44+
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
45+
# with:
46+
# submodules: "recursive"
47+
#
48+
# - name: Set up Docker Buildx
49+
# uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
50+
#
51+
# - name: Setup env
52+
# shell: bash
53+
# run: |
54+
# echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
55+
# echo CI=1 >> $GITHUB_ENV
56+
# echo $(pwd)/bin >> $GITHUB_PATH
57+
# echo CI=1 >> .env
58+
# echo IN_DOCKER=1 >> .env
59+
#
60+
# - name: Download setup key
61+
# shell: bash
62+
# run: |
63+
# if [ -f "/setup_2^26.key" ]; then
64+
# cp '/setup_2^26.key' './setup_2^26.key'
65+
# else
66+
# run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
67+
# fi
68+
#
69+
# - name: Set env vars
70+
# shell: bash
71+
# run: |
72+
# echo PLATFORM=$(echo ${{ matrix.platforms }} | tr '/' '-') >> $GITHUB_ENV
73+
# if [ -n "${{ inputs.image_tag_suffix }}" ]; then
74+
# echo IMAGE_TAG_SHA_TS="${{ env.IMAGE_TAG_SUFFIX }}" >> $GITHUB_ENV
75+
# else
76+
# echo IMAGE_TAG_SHA_TS=$(git rev-parse --short HEAD)-$(date +%s) >> $GITHUB_ENV
77+
# fi
78+
#
79+
# - name: Download contracts
80+
# uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
81+
# with:
82+
# name: contacts
83+
# path: |
84+
# ./contracts
85+
#
86+
# - name: login to Docker registries
87+
# if: ${{ inputs.action == 'push' }}
88+
# shell: bash
89+
# run: |
90+
# docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
91+
# gcloud auth configure-docker us-docker.pkg.dev -q
92+
#
93+
# - name: Login to GitHub Container Registry
94+
# uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
95+
# if: ${{ inputs.action == 'push' }}
96+
# with:
97+
# registry: ghcr.io
98+
# username: ${{ github.actor }}
99+
# password: ${{ secrets.GITHUB_TOKEN }}
100+
#
101+
# - name: Build docker image
102+
# uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
103+
# with:
104+
# context: .
105+
# load: true
106+
# platforms: ${{ matrix.platforms }}
107+
# file: docker/${{ matrix.components }}/Dockerfile
108+
# build-args: |
109+
# SCCACHE_GCS_BUCKET=matterlabs-infra-sccache-storage
110+
# SCCACHE_GCS_SERVICE_ACCOUNT=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com
111+
# SCCACHE_GCS_RW_MODE=READ_WRITE
112+
# RUSTC_WRAPPER=sccache
113+
# tags: |
114+
# us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
115+
# ghcr.io/${{ github.repository_owner }}/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
116+
# matterlabs/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
117+
#
118+
# - name: Push docker image
119+
# if: ${{ inputs.action == 'push' }}
120+
# run: |
121+
# docker push us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
122+
# docker push matterlabs/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
123+
# docker push ghcr.io/${{ github.repository_owner }}/${{ matrix.components }}:${{ env.IMAGE_TAG_SHA_TS }}-${{ env.PLATFORM }}
124+
125+
# create_manifest:
126+
# name: Create release manifest
127+
# runs-on: matterlabs-ci-runner
128+
# needs: build-images
129+
# if: ${{ inputs.action == 'push' }}
130+
# strategy:
131+
# matrix:
132+
# component:
133+
# - name: server-v2
134+
# platform: linux/amd64
135+
# - name: external-node
136+
# platform: linux/amd64,linux/arm64
137+
# - name: snapshots-creator
138+
# platform: linux/amd64
139+
#
140+
# env:
141+
# IMAGE_TAG_SUFFIX: ${{ inputs.image_tag_suffix }}${{ (inputs.en_alpha_release && matrix.component.name == 'external-node') && '-alpha' || '' }}
142+
# steps:
143+
# - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
144+
#
145+
# - name: login to Docker registries
146+
# run: |
147+
# docker login -u ${{ secrets.DOCKERHUB_USER }} -p ${{ secrets.DOCKERHUB_TOKEN }}
148+
# gcloud auth configure-docker us-docker.pkg.dev -q
149+
#
150+
# - name: Create Docker manifest
151+
# run: |
152+
# docker_repositories=("matterlabs/${{ matrix.component.name }}" "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ matrix.component.name }}")
153+
# platforms=${{ matrix.component.platform }}
154+
# for repo in "${docker_repositories[@]}"; do
155+
# platform_tags=""
156+
# for platform in ${platforms//,/ }; do
157+
# platform=$(echo $platform | tr '/' '-')
158+
# platform_tags+=" --amend ${repo}:${IMAGE_TAG_SUFFIX}-${platform}"
159+
# done
160+
# for manifest in "${repo}:${IMAGE_TAG_SUFFIX}" "${repo}:2.0-${IMAGE_TAG_SUFFIX}" "${repo}:latest" "${repo}:latest2.0"; do
161+
# docker manifest create ${manifest} ${platform_tags}
162+
# docker manifest push ${manifest}
163+
# done
164+
# done

.github/workflows/MAIN_build-contracts.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on:
2929
type: string
3030
description: SHA commit for build
3131
required: false
32-
# pull_request: # TODO: remove after testing
32+
pull_request: # TODO: remove after testing
3333

3434
# Do not cancel runs, put new merges in queue
3535
concurrency:
@@ -61,12 +61,13 @@ jobs:
6161
id: changed-files
6262
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
6363
with:
64+
fetch_additional_submodule_history: true
6465
files: |
6566
contracts
6667
contracts/**
6768
6869
- name: Define contracts commit
69-
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
70+
# if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
7071
id: contracts-commit
7172
run: echo "commit=$(cd contracts && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
7273

@@ -80,7 +81,7 @@ jobs:
8081
prebuild-contracts:
8182
needs: check-contracts
8283
runs-on: matterlabs-ci-runner-highmem-long
83-
if: ${{ needs.check-release.outputs.commit != '' }}
84+
if: ${{ needs.check-contracts.outputs.commit != '' }}
8485
steps:
8586
- name: Checkout
8687
uses: actions/checkout@v4

.github/workflows/MAIN_build-zkstack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313

1414
# Define the events that triggers the workflow
1515
on:
16-
pull_request: # TODO: remove after testing
16+
# pull_request: # TODO: remove after testing
1717
push:
1818
branches:
1919
- main

.github/workflows/MAIN_cache-regen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ on:
3535
# Run clean up and full regen once a month
3636
schedule:
3737
- cron: '0 0 1 * *'
38-
pull_request: # TODO: remove after testing
38+
# pull_request: # TODO: remove after testing
3939

4040

4141
# Do not cancel runs, put new merges in queue

.github/workflows/re-using/build-docker-common.yaml renamed to .github/workflows/REUSED_build-docker-common.yaml

Lines changed: 70 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
version:
2222
type: string
2323
description: 'Docker image version.'
24-
required: true
24+
required: false
2525

2626

2727
# Use bash shell with verbose output
@@ -31,13 +31,16 @@ defaults:
3131

3232
# Add write permissions to the ghcr.io docker repository
3333
permissions:
34+
contents: read
3435
packages: write
3536

3637
jobs:
3738

3839
build:
3940
name: Build ${{ matrix.platform }}
40-
runs-on: ubuntu-latest
41+
permissions:
42+
contents: read
43+
packages: write
4144
strategy:
4245
fail-fast: false
4346
matrix:
@@ -46,6 +49,7 @@ jobs:
4649
runner: matterlabs-ci-runner-high-performance
4750
- platform: arm64
4851
runner: matterlabs-ci-runner-arm
52+
runs-on: ${{ matrix.runner }}
4953
steps:
5054
- name: Checkout
5155
uses: actions/checkout@v4
@@ -63,6 +67,19 @@ jobs:
6367
username: ${{ github.repository_owner }}
6468
password: ${{ github.token }}
6569

70+
- name: Download setup key
71+
shell: bash
72+
run: |
73+
if [ -f "/setup_2^26.key" ]; then
74+
cp '/setup_2^26.key' './setup_2^26.key'
75+
else
76+
curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
77+
fi
78+
79+
# Download prebuilt contracts version if exists, otherwise build them
80+
- name: Build contracts
81+
uses: matter-labs/zksync-ci-common/.github/actions/build-contracts@aba-ci-optimize
82+
6683
- name: Docker meta
6784
id: meta
6885
uses: docker/metadata-action@v5
@@ -72,7 +89,7 @@ jobs:
7289
matterlabs/${{ inputs.image }}
7390
7491
- name: Define whether to save cache
75-
# if: github.event_name != 'pull_request'
92+
# if: github.event_name != 'pull_request' # TODO: uncomment before merging to main
7693
id: set-cache-to
7794
run: echo "cache-to=type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}:buildcache-${{ matrix.platform }},mode=max" >> "${GITHUB_OUTPUT}"
7895

@@ -89,7 +106,8 @@ jobs:
89106
labels: ${{ steps.meta.outputs.labels }}
90107
cache-from: 'type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}:buildcache-${{ matrix.platform }}'
91108
cache-to: ${{ steps.set-cache-to.outputs.cache-to }}
92-
outputs: type=image,"name=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }},matterlabs/${{ inputs.image }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
109+
outputs: type=image,"name=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
110+
# outputs: type=image,"name=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }},matterlabs/${{ inputs.image }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
93111

94112
- name: Export digest
95113
run: |
@@ -105,51 +123,51 @@ jobs:
105123
if-no-files-found: error
106124
retention-days: 1
107125

108-
merge:
109-
runs-on: matterlabs-ci-runner-high-performance
110-
needs: build
111-
steps:
112-
- name: Download digests
113-
uses: actions/download-artifact@v4
114-
with:
115-
path: ${{ runner.temp }}/digests
116-
pattern: digests-*
117-
merge-multiple: true
118-
119-
- name: Log in to Docker Hub
120-
uses: docker/login-action@v3
121-
with:
122-
username: ${{ secrets.dockerhub_user }}
123-
password: ${{ secrets.dockerhub_token }}
124-
125-
- name: Login to GHCR
126-
uses: docker/login-action@v3
127-
with:
128-
registry: ghcr.io
129-
username: ${{ github.repository_owner }}
130-
password: ${{ github.token }}
131-
132-
- name: Set up Docker Buildx
133-
uses: docker/setup-buildx-action@v3
134-
135-
- name: Docker meta
136-
id: meta
137-
uses: docker/metadata-action@v5
138-
with:
139-
images: |
140-
ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}
141-
matterlabs/${{ inputs.image }}
142-
143-
- name: Create manifest list and push
144-
working-directory: ${{ runner.temp }}/digests
145-
shell: bash -ex {0}
146-
run: |
147-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
148-
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}@sha256:%s ' *)
149-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
150-
$(printf 'matterlabs/${{ inputs.image }}@sha256:%s ' *)
151-
152-
- name: Inspect image
153-
run: |
154-
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}:${{ inputs.version }}
155-
docker buildx imagetools inspect matterlabs/${{ inputs.image }}:${{ inputs.version }}
126+
merge:
127+
runs-on: ubuntu-latest
128+
needs: build
129+
steps:
130+
- name: Download digests
131+
uses: actions/download-artifact@v4
132+
with:
133+
path: ${{ runner.temp }}/digests
134+
pattern: digests-*
135+
merge-multiple: true
136+
137+
- name: Log in to Docker Hub
138+
uses: docker/login-action@v3
139+
with:
140+
username: ${{ secrets.dockerhub_user }}
141+
password: ${{ secrets.dockerhub_token }}
142+
143+
- name: Login to GHCR
144+
uses: docker/login-action@v3
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.repository_owner }}
148+
password: ${{ github.token }}
149+
150+
- name: Set up Docker Buildx
151+
uses: docker/setup-buildx-action@v3
152+
153+
- name: Docker meta
154+
id: meta
155+
uses: docker/metadata-action@v5
156+
with:
157+
images: |
158+
ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}
159+
# matterlabs/${{ inputs.image }}
160+
161+
- name: Create manifest list and push
162+
working-directory: ${{ runner.temp }}/digests
163+
shell: bash -ex {0}
164+
run: |
165+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
166+
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}@sha256:%s ' *)
167+
# docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
168+
# $(printf 'matterlabs/${{ inputs.image }}@sha256:%s ' *)
169+
170+
# - name: Inspect image
171+
# run: |
172+
# docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}:${{ inputs.version }}
173+
# docker buildx imagetools inspect matterlabs/${{ inputs.image }}:${{ inputs.version }}

0 commit comments

Comments
 (0)