-
Notifications
You must be signed in to change notification settings - Fork 2.1k
261 lines (224 loc) · 8.88 KB
/
docker_build_base.yml
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: Docker Build Base
on:
push:
branches:
- main
tags:
- '*'
concurrency:
group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Base')
cancel-in-progress: true
permissions: read-all
jobs:
build_and_push_base:
name: Build and push vitess/base Docker images
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess'
strategy:
fail-fast: true
matrix:
branch: [ latest, mysql57, percona57, percona80 ]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Dockerfile path
run: |
if [[ "${{ matrix.branch }}" == "latest" ]]; then
echo "DOCKERFILE=./docker/base/Dockerfile" >> $GITHUB_ENV
else
echo "DOCKERFILE=./docker/base/Dockerfile.${{ matrix.branch }}" >> $GITHUB_ENV
fi
- name: Build and push on main
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE }}
push: true
tags: vitess/base:${{ matrix.branch }}
######
# All code below only applies to new tags
######
- name: Get the Git tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Set Docker tag name
if: startsWith(github.ref, 'refs/tags/') && matrix.branch == 'latest'
run: |
if [[ "${{ matrix.branch }}" == "latest" ]]; then
echo "DOCKER_TAG=vitess/base:${TAG_NAME}" >> $GITHUB_ENV
fi
- name: Build and push on tags
if: startsWith(github.ref, 'refs/tags/') && matrix.branch == 'latest'
uses: docker/build-push-action@v5
with:
context: .
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ env.DOCKER_TAG }}
build_and_push_k8s:
needs: build_and_push_base
name: Build and push vitess/k8s image
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess'
strategy:
fail-fast: true
matrix:
debian: [ bullseye, bookworm ]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Docker context path
run: |
echo "DOCKER_CTX=./docker/k8s" >> $GITHUB_ENV
- name: Build and push on main latest tag
if: github.ref == 'refs/heads/main' && matrix.debian == 'bookworm'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: vitess/k8s:latest
build-args: |
VT_BASE_VER=latest
DEBIAN_VER=${{ matrix.debian }}-slim
- name: Build and push on main debian specific tag
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: vitess/k8s:latest-${{ matrix.debian }}
build-args: |
VT_BASE_VER=latest
DEBIAN_VER=${{ matrix.debian }}-slim
######
# All code below only applies to new tags
######
- name: Get the Git tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# We push git-tag-based k8s image to three tags, i.e. for 'v19.0.0' we push to:
#
# vitess/k8s:v19.0.0 (DOCKER_TAG_DEFAULT_DEBIAN)
# vitess/k8s:v19.0.0-bookworm (DOCKER_TAG)
# vitess/k8s:v19.0.0-bullseye (DOCKER_TAG)
#
- name: Set Docker tag name
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "DOCKER_TAG_DEFAULT_DEBIAN=vitess/k8s:${TAG_NAME}" >> $GITHUB_ENV
echo "DOCKER_TAG=vitess/k8s:${TAG_NAME}-${{ matrix.debian }}" >> $GITHUB_ENV
# Build and Push component image to DOCKER_TAG, applies to both debian version
- name: Build and push on tags using Debian extension
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: ${{ env.DOCKER_TAG }}
build-args: |
VT_BASE_VER=${{ env.TAG_NAME }}
DEBIAN_VER=${{ matrix.debian }}-slim
# Build and Push component image to DOCKER_TAG_DEFAULT_DEBIAN, only applies when building the default Debian version (bookworm)
# It is fine to build a second time here when "matrix.debian == 'bookworm'" as we have cached the first build already
- name: Build and push on tags without Debian extension
if: startsWith(github.ref, 'refs/tags/') && matrix.debian == 'bookworm'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }}
build-args: |
VT_BASE_VER=${{ env.TAG_NAME }}
DEBIAN_VER=${{ matrix.debian }}-slim
build_and_push_components:
needs: build_and_push_k8s
name: Build and push vitess components Docker images
runs-on: gh-hosted-runners-16cores-1
if: github.repository == 'vitessio/vitess'
strategy:
fail-fast: true
matrix:
debian: [ bullseye, bookworm ]
component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, logrotate, logtail ]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Docker context path
run: |
echo "DOCKER_CTX=./docker/k8s/${{ matrix.component }}" >> $GITHUB_ENV
- name: Build and push on main latest tag
if: github.ref == 'refs/heads/main' && matrix.debian == 'bookworm'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: vitess/${{ matrix.component }}:latest
build-args: |
VT_BASE_VER=latest
DEBIAN_VER=${{ matrix.debian }}-slim
- name: Build and push on main debian specific tag
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }}
build-args: |
VT_BASE_VER=latest
DEBIAN_VER=${{ matrix.debian }}-slim
######
# All code below only applies to new tags
######
- name: Get the Git tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# We push git-tag-based images to three tags, i.e. for 'v19.0.0' we push to:
#
# vitess/${{ matrix.component }}:v19.0.0 (DOCKER_TAG_DEFAULT_DEBIAN)
# vitess/${{ matrix.component }}:v19.0.0-bookworm (DOCKER_TAG)
# vitess/${{ matrix.component }}:v19.0.0-bullseye (DOCKER_TAG)
#
- name: Set Docker tag name
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "DOCKER_TAG_DEFAULT_DEBIAN=vitess/${{ matrix.component }}:${TAG_NAME}" >> $GITHUB_ENV
echo "DOCKER_TAG=vitess/${{ matrix.component }}:${TAG_NAME}-${{ matrix.debian }}" >> $GITHUB_ENV
# Build and Push component image to DOCKER_TAG, applies to both debian version
- name: Build and push on tags using Debian extension
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: ${{ env.DOCKER_TAG }}
build-args: |
VT_BASE_VER=${{ env.TAG_NAME }}
DEBIAN_VER=${{ matrix.debian }}-slim
# Build and Push component image to DOCKER_TAG_DEFAULT_DEBIAN, only applies when building the default Debian version (bookworm)
# It is fine to build a second time here when "matrix.debian == 'bookworm'" as we have cached the first build already
- name: Build and push on tags without Debian extension
if: startsWith(github.ref, 'refs/tags/') && matrix.debian == 'bookworm'
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }}
build-args: |
VT_BASE_VER=${{ env.TAG_NAME }}
DEBIAN_VER=${{ matrix.debian }}-slim