1
+ name : 2CI-CD build and deploy docker images based on the last commit in the main branch
2
+ run-name : " Commit id ${{ github.sha }}: CI-CD build and deploy docker images based on the commit id in the main branch"
3
+
4
+ env :
5
+ APPLICATION : " erigon"
6
+ BUILDER_IMAGE : " golang:1.23.1-alpine3.20"
7
+ TARGET_BASE_IMAGE : " alpine:3.20.3"
8
+ APP_REPO : " erigontech/erigon"
9
+ CHECKOUT_REF : " main"
10
+ DOCKERHUB_REPOSITORY : " erigontech/erigon"
11
+ LABEL_DESCRIPTION : " [docker image built on a last commit id from the main branch] Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency frontier. Archive Node by default."
12
+
13
+ on :
14
+ push :
15
+ branches :
16
+ - ' main'
17
+ paths-ignore :
18
+ - ' .github/**'
19
+ workflow_dispatch :
20
+
21
+ jobs :
22
+
23
+ Build :
24
+ runs-on : ubuntu-22.04
25
+ timeout-minutes : 45
26
+
27
+ steps :
28
+ - name : Fast checkout git repository
29
+ uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # # 4.1.7 release
30
+ with :
31
+ repository : ${{ env.APP_REPO }}
32
+ fetch-depth : 1
33
+ ref : ${{ env.CHECKOUT_REF }}
34
+ path : ' erigon'
35
+
36
+ - name : Setup go env and cache
37
+ uses : actions/setup-go@v5
38
+ with :
39
+ go-version : ' >=1.22'
40
+ go-version-file : ' erigon/go.mod'
41
+ cache-dependency-path : |
42
+ erigon/go.sum
43
+
44
+ - name : Get commit id
45
+ id : getCommitId
46
+ run : |
47
+ cd erigon
48
+ echo "id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
49
+ echo "short_commit_id=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
50
+ cd ..
51
+
52
+ - name : Login to Docker Hub
53
+ uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # # v3.3.0
54
+ with :
55
+ username : ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }}
56
+ password : ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }}
57
+
58
+ - name : Set up QEMU
59
+ uses : docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # # v3.2.0
60
+
61
+ - name : Set up Docker Buildx
62
+ uses : docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # # v3.6.1
63
+
64
+ - name : Build arm64
65
+ run : |
66
+ docker run --platform linux/arm64 \
67
+ --rm -v $(pwd)/erigon:/erigon:ro \
68
+ -v $(pwd)/build-arm64:/erigon-build \
69
+ -v ${HOME}/.cache/go-build/arm64:/root/.cache/go-build \
70
+ -v ${HOME}/go/pkg/mod:/go/pkg/mod \
71
+ -w /erigon --entrypoint /bin/sh \
72
+ ${{ env.BUILDER_IMAGE }} \
73
+ -c "apk update; apk add make git gcc libstdc++ build-base linux-headers bash ca-certificates; git config --global --add safe.directory /erigon; make GOARCH=arm64 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon"
74
+
75
+ - name : Build amd64
76
+ run : |
77
+ docker run --platform linux/amd64 \
78
+ --rm -v $(pwd)/erigon:/erigon:ro \
79
+ -v $(pwd)/build-amd64:/erigon-build \
80
+ -v ${HOME}/.cache/go-build/amd64:/root/.cache/go-build \
81
+ -v ${HOME}/go/pkg/mod:/go/pkg/mod \
82
+ -w /erigon --entrypoint /bin/sh \
83
+ ${{ env.BUILDER_IMAGE }} \
84
+ -c "apk update; apk add make git gcc libstdc++ build-base linux-headers bash ca-certificates; git config --global --add safe.directory /erigon; make GOARCH=amd64 GOAMD64=v2 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon"
85
+
86
+ - name : Build and push multi-platform docker image based on the commit id ${{ steps.getCommitId.outputs.short_commit_id }} in the main branch
87
+ env :
88
+ BUILD_VERSION : " main-${{ steps.getCommitId.outputs.short_commit_id }}"
89
+ DOCKER_URL : ${{ env.DOCKERHUB_REPOSITORY }}
90
+ DOCKERFILE_PATH : Dockerfile.release
91
+ run : |
92
+ cp -vr build-amd64 erigon/
93
+ cp -vr build-arm64 erigon/
94
+ cd erigon
95
+ docker buildx build \
96
+ --file ${{ env.DOCKERFILE_PATH }} \
97
+ --target ci-cd-main-branch \
98
+ --attest type=provenance,mode=max \
99
+ --sbom=true \
100
+ --build-arg CI_CD_MAIN_TARGET_BASE_IMAGE=${{ env.TARGET_BASE_IMAGE }} \
101
+ --build-arg CI_CD_MAIN_BUILDER_IMAGE=${{ env.BUILDER_IMAGE }} \
102
+ --tag ${{ env.DOCKER_URL }}:${{ env.BUILD_VERSION }} \
103
+ --tag ${{ env.DOCKER_URL }}:main-latest \
104
+ --label org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
105
+ --label org.opencontainers.image.authors="https://github.com/erigontech/erigon/graphs/contributors" \
106
+ --label org.opencontainers.image.url="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
107
+ --label org.opencontainers.image.documentation="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
108
+ --label org.opencontainers.image.source="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
109
+ --label org.opencontainers.image.version=${{ steps.getCommitId.outputs.id }} \
110
+ --label org.opencontainers.image.revision=${{ steps.getCommitId.outputs.id }} \
111
+ --label org.opencontainers.image.vcs-ref-short=${{ steps.getCommitId.outputs.short_commit_id }} \
112
+ --label org.opencontainers.image.vendor="${{ github.repository_owner }}" \
113
+ --label org.opencontainers.image.description="${{ env.LABEL_DESCRIPTION }}" \
114
+ --label org.opencontainers.image.base.name="${{ env.TARGET_BASE_IMAGE }}" \
115
+ --push \
116
+ --platform linux/amd64,linux/arm64 .
117
+
118
+ - name : Print docker images published
119
+ run : |
120
+ echo The following docker images have been published:
121
+ echo "${{ env.DOCKERHUB_REPOSITORY }}:main-${{ steps.getCommitId.outputs.short_commit_id }}"
122
+ echo "${{ env.DOCKERHUB_REPOSITORY }}:main-latest"
123
+
124
+ # # upload commit id for use in test-kurtosis-assertoor.yml
125
+ # # reference: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#using-data-from-the-triggering-workflow
126
+ - name : Save commit id
127
+ run : |
128
+ mkdir -p ./COMMIT_ID_DOCKER_BUILD
129
+ echo "${{ steps.getCommitId.outputs.short_commit_id }}" >> ./COMMIT_ID_DOCKER_BUILD/commit
130
+
131
+ - uses : actions/upload-artifact@v4
132
+ with :
133
+ name : commit
134
+ path : COMMIT_ID_DOCKER_BUILD
135
+
0 commit comments