43
43
uses : docker/setup-qemu-action@v3
44
44
45
45
- name : Set up Docker Buildx
46
+ id : buildx
46
47
uses : docker/setup-buildx-action@v3
47
48
48
49
- name : Cache Docker layers
@@ -53,34 +54,178 @@ jobs:
53
54
restore-keys : |
54
55
${{ runner.os }}-buildx-
55
56
57
+ # Build multi platform images and loading them at the same time is not possible with default container runtime : https://github.com/docker/buildx/issues/59
58
+ # So let's use containerd instead as it supports this option
59
+ # Also containerd is one of the option to allow preserving provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
60
+ - name : Setup docker with containerd
61
+ uses : crazy-max/ghaction-setup-docker@v3
62
+ with :
63
+ daemon-config : |
64
+ {
65
+ "features": {
66
+ "containerd-snapshotter": true
67
+ }
68
+ }
69
+
70
+ - name : Build docker image
71
+ id : docker_build
72
+ uses : docker/build-push-action@v5
73
+ with :
74
+ builder : ${{ steps.buildx.outputs.name }}
75
+ context : api
76
+ platforms : linux/amd64,linux/arm64
77
+ provenance : mode=min
78
+ sbom : true
79
+ push : false
80
+ load : true
81
+ tags : |
82
+ kafka-ui:temp
83
+ build-args : |
84
+ JAR_FILE=api-${{ steps.build.outputs.version }}.jar
85
+ cache-from : type=local,src=/tmp/.buildx-cache
86
+ cache-to : type=local,dest=/tmp/.buildx-cache
87
+
88
+ - name : Dump docker image
89
+ run : |
90
+ docker image save kafka-ui:temp > /tmp/image.tar
91
+
92
+ - name : Upload docker image
93
+ uses : actions/upload-artifact@v4
94
+ with :
95
+ name : image
96
+ path : /tmp/image.tar
97
+ retention-days : 1
98
+
99
+ deploy-ghcr :
100
+ runs-on : ubuntu-latest
101
+ needs : build
102
+ permissions :
103
+ packages : write
104
+
105
+ steps :
106
+ - name : Download docker image
107
+ uses : actions/download-artifact@v4
108
+ with :
109
+ name : image
110
+ path : /tmp
111
+
112
+ # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
113
+ - name : Setup docker with containerd
114
+ uses : crazy-max/ghaction-setup-docker@v3
115
+ with :
116
+ daemon-config : |
117
+ {
118
+ "features": {
119
+ "containerd-snapshotter": true
120
+ }
121
+ }
122
+
123
+ - name : Load docker image into daemon
124
+ run : |
125
+ docker load --input /tmp/image.tar
126
+
56
127
- name : Login to GitHub Container Registry
57
128
uses : docker/login-action@v3
58
129
with :
59
130
registry : ghcr.io
60
- username : ${{ github.actor }}
131
+ username : " ${{ github.actor }}"
61
132
password : ${{ secrets.GITHUB_TOKEN }}
62
133
134
+ - name : Push images to GHCR
135
+ run : |
136
+ docker tag kafka-ui:temp ghcr.io/kafbat/kafka-ui:main
137
+ docker tag kafka-ui:temp ghcr.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
138
+ docker push ghcr.io/kafbat/kafka-ui:main
139
+ docker push ghcr.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
140
+
141
+ deploy-dockerhub :
142
+ runs-on : ubuntu-latest
143
+ needs : build
144
+
145
+ steps :
146
+ - name : Download docker image
147
+ uses : actions/download-artifact@v4
148
+ with :
149
+ name : image
150
+ path : /tmp
151
+
152
+ # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
153
+ - name : Setup docker with containerd
154
+ uses : crazy-max/ghaction-setup-docker@v3
155
+ with :
156
+ daemon-config : |
157
+ {
158
+ "features": {
159
+ "containerd-snapshotter": true
160
+ }
161
+ }
162
+
163
+ - name : Load docker image into daemon
164
+ run : |
165
+ docker load --input /tmp/image.tar
166
+
63
167
- name : Login to Dockerhub
64
168
uses : docker/login-action@v3
65
169
with :
66
170
username : ${{ secrets.DOCKERHUB_USERNAME }}
67
171
password : ${{ secrets.DOCKERHUB_TOKEN }}
172
+
173
+ - name : Push images to dockerhub
174
+ run : |
175
+ docker tag kafka-ui:temp docker.io/kafbat/kafka-ui:main
176
+ docker tag kafka-ui:temp docker.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
177
+ docker push docker.io/kafbat/kafka-ui:main
178
+ docker push docker.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
68
179
69
- - name : Build & push docker image
70
- id : docker_build_and_push
71
- uses : docker/build-push-action@v5
180
+
181
+ deploy-ecr :
182
+ runs-on : ubuntu-latest
183
+ needs : build
184
+ permissions :
185
+ contents : read # To read secrets
186
+ id-token : write # This is required for requesting the JWT
187
+
188
+ steps :
189
+ - name : Download docker image
190
+ uses : actions/download-artifact@v4
72
191
with :
73
- builder : ${{ steps.buildx.outputs.name }}
74
- context : api
75
- platforms : linux/amd64,linux/arm64
76
- provenance : false
77
- push : true
78
- tags : |
79
- ghcr.io/kafbat/kafka-ui:${{ steps.build.outputs.version }}
80
- ghcr.io/kafbat/kafka-ui:main
81
- kafbat/kafka-ui:${{ steps.build.outputs.version }}
82
- kafbat/kafka-ui:main
83
- build-args : |
84
- JAR_FILE=api-${{ steps.build.outputs.version }}.jar
85
- cache-from : type=local,src=/tmp/.buildx-cache
86
- cache-to : type=local,dest=/tmp/.buildx-cache
192
+ name : image
193
+ path : /tmp
194
+
195
+ # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
196
+ - name : Setup docker with containerd
197
+ uses : crazy-max/ghaction-setup-docker@v3
198
+ with :
199
+ daemon-config : |
200
+ {
201
+ "features": {
202
+ "containerd-snapshotter": true
203
+ }
204
+ }
205
+
206
+ - name : Load docker image into daemon
207
+ run : |
208
+ docker load --input /tmp/image.tar
209
+
210
+ - name : Configure AWS credentials
211
+ uses : aws-actions/configure-aws-credentials@v4
212
+ with :
213
+ aws-region : us-east-1 # This region only for public ECR
214
+ role-to-assume : ${{ secrets.AWS_ROLE }}
215
+
216
+ - name : Login to public ECR
217
+ id : login-ecr-public
218
+ uses : aws-actions/amazon-ecr-login@v2
219
+ with :
220
+ registry-type : public
221
+
222
+ - name : Push to ECR
223
+ env :
224
+ REGISTRY : ${{steps.login-ecr-public.outputs.registry }}
225
+ REGISTRY_ALIAS : j4u0y1h1
226
+ REPOSITORY : kafka-ui
227
+ run : |
228
+ docker tag kafka-ui:temp $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:main
229
+ docker tag kafka-ui:temp $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:${{ needs.build.outputs.version }}
230
+ docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:main
231
+ docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:${{ needs.build.outputs.version }}
0 commit comments