6
6
- " .github/workflows/release.yml"
7
7
- " src/**"
8
8
- " migrations/**"
9
- - " hooks/**"
10
9
- " docker/**"
11
10
- " Cargo.*"
12
11
- " build.rs"
15
14
16
15
branches : # Only on paths above
17
16
- main
17
+ - release-build-revision
18
18
19
19
tags : # Always, regardless of paths above
20
20
- ' *'
@@ -35,23 +35,20 @@ jobs:
35
35
with :
36
36
cancel_others : ' true'
37
37
# Only run this when not creating a tag
38
- if : ${{ startsWith( github.ref, 'refs/heads/') }}
38
+ if : ${{ github.ref_type == 'branch' }}
39
39
40
40
docker-build :
41
41
runs-on : ubuntu-22.04
42
42
timeout-minutes : 120
43
43
needs : skip_check
44
- # Start a local docker registry to be used to generate multi-arch images.
45
- services :
46
- registry :
47
- image : registry:2
48
- ports :
49
- - 5000:5000
44
+ if : ${{ needs.skip_check.outputs.should_skip != 'true' && github.repository == 'dani-garcia/vaultwarden' }}
45
+ # TODO: Start a local docker registry to be used to extract the final Alpine static build images
46
+ # services:
47
+ # registry:
48
+ # image: registry:2
49
+ # ports:
50
+ # - 5000:5000
50
51
env :
51
- # Use BuildKit (https://docs.docker.com/build/buildkit/) for better
52
- # build performance and the ability to copy extended file attributes
53
- # (e.g., for executable capabilities) across build phases.
54
- DOCKER_BUILDKIT : 1
55
52
SOURCE_COMMIT : ${{ github.sha }}
56
53
SOURCE_REPOSITORY_URL : " https://github.com/${{ github.repository }}"
57
54
# The *_REPO variables need to be configured as repository variables
65
62
# QUAY_REPO needs to be 'quay.io/<user>/<repo>'
66
63
# Check for Quay.io credentials in secrets
67
64
HAVE_QUAY_LOGIN : ${{ vars.QUAY_REPO != '' && secrets.QUAY_USERNAME != '' && secrets.QUAY_TOKEN != '' }}
68
- if : ${{ needs.skip_check.outputs.should_skip != 'true' && github.repository == 'dani-garcia/vaultwarden' }}
69
65
strategy :
70
66
matrix :
71
67
base_image : ["debian","alpine"]
@@ -77,18 +73,43 @@ jobs:
77
73
with :
78
74
fetch-depth : 0
79
75
80
- # Determine Docker Tag
81
- - name : Init Variables
82
- id : vars
76
+ - name : Initialize QEMU binfmt support
77
+ uses : docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
78
+ with :
79
+ platforms : " arm64,arm"
80
+
81
+ # Start Docker Buildx
82
+ - name : Setup Docker Buildx
83
+ uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
84
+ # https://github.com/moby/buildkit/issues/3969
85
+ # Also set max parallelism to 2, the default of 4 breaks GitHub Actions
86
+ with :
87
+ config-inline : |
88
+ [worker.oci]
89
+ max-parallelism = 2
90
+ driver-opts : |
91
+ network=host
92
+
93
+ # Determine Base Tags and Source Version
94
+ - name : Determine Base Tags and Source Version
83
95
shell : bash
84
96
run : |
85
- # Check which main tag we are going to build determined by github.ref
86
- if [[ "${{ github.ref }}" == refs/tags/* ]]; then
87
- echo "DOCKER_TAG=${GITHUB_REF#refs/*/}" | tee -a "${GITHUB_OUTPUT}"
88
- elif [[ "${{ github.ref }}" == refs/heads/* ]]; then
89
- echo "DOCKER_TAG=testing" | tee -a "${GITHUB_OUTPUT}"
97
+ # Check which main tag we are going to build determined by github.ref_type
98
+ if [[ "${{ github.ref_type }}" == "tag" ]]; then
99
+ echo "BASE_TAGS=latest,${GITHUB_REF#refs/*/}" | tee -a "${GITHUB_ENV}"
100
+ elif [[ "${{ github.ref_type }}" == "branch" ]]; then
101
+ echo "BASE_TAGS=testing" | tee -a "${GITHUB_ENV}"
102
+ fi
103
+
104
+ # Get the Source Version for this release
105
+ GIT_EXACT_TAG="$(git describe --tags --abbrev=0 --exact-match 2>/dev/null || true)"
106
+ if [[ -n "${GIT_EXACT_TAG}" ]]; then
107
+ echo "SOURCE_VERSION=${GIT_EXACT_TAG}" | tee -a "${GITHUB_ENV}"
108
+ else
109
+ GIT_LAST_TAG="$(git describe --tags --abbrev=0)"
110
+ echo "SOURCE_VERSION=${GIT_LAST_TAG}-${SOURCE_COMMIT:0:8}" | tee -a "${GITHUB_ENV}"
90
111
fi
91
- # End Determine Docker Tag
112
+ # End Determine Base Tags
92
113
93
114
# Login to Docker Hub
94
115
- name : Login to Docker Hub
@@ -98,6 +119,12 @@ jobs:
98
119
password : ${{ secrets.DOCKERHUB_TOKEN }}
99
120
if : ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
100
121
122
+ - name : Add registry for DockerHub
123
+ if : ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
124
+ shell : bash
125
+ run : |
126
+ echo "CONTAINER_REGISTRIES=${{ vars.DOCKERHUB_REPO }}" | tee -a "${GITHUB_ENV}"
127
+
101
128
# Login to GitHub Container Registry
102
129
- name : Login to GitHub Container Registry
103
130
uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
@@ -107,6 +134,12 @@ jobs:
107
134
password : ${{ secrets.GITHUB_TOKEN }}
108
135
if : ${{ env.HAVE_GHCR_LOGIN == 'true' }}
109
136
137
+ - name : Add registry for ghcr.io
138
+ if : ${{ env.HAVE_GHCR_LOGIN == 'true' }}
139
+ shell : bash
140
+ run : |
141
+ echo "CONTAINER_REGISTRIES=${CONTAINER_REGISTRIES:+${CONTAINER_REGISTRIES},}${{ vars.GHCR_REPO }}" | tee -a "${GITHUB_ENV}"
142
+
110
143
# Login to Quay.io
111
144
- name : Login to Quay.io
112
145
uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
@@ -116,120 +149,22 @@ jobs:
116
149
password : ${{ secrets.QUAY_TOKEN }}
117
150
if : ${{ env.HAVE_QUAY_LOGIN == 'true' }}
118
151
119
- # Debian
120
-
121
- # Docker Hub
122
- - name : Build Debian based images (docker.io)
123
- shell : bash
124
- env :
125
- DOCKER_REPO : " ${{ vars.DOCKERHUB_REPO }}"
126
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
127
- run : |
128
- ./hooks/build
129
- if : ${{ matrix.base_image == 'debian' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
130
-
131
- - name : Push Debian based images (docker.io)
132
- shell : bash
133
- env :
134
- DOCKER_REPO : " ${{ vars.DOCKERHUB_REPO }}"
135
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
136
- run : |
137
- ./hooks/push
138
- if : ${{ matrix.base_image == 'debian' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
139
-
140
- # GitHub Container Registry
141
- - name : Build Debian based images (ghcr.io)
142
- shell : bash
143
- env :
144
- DOCKER_REPO : " ${{ vars.GHCR_REPO }}"
145
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
146
- run : |
147
- ./hooks/build
148
- if : ${{ matrix.base_image == 'debian' && env.HAVE_GHCR_LOGIN == 'true' }}
149
-
150
- - name : Push Debian based images (ghcr.io)
151
- shell : bash
152
- env :
153
- DOCKER_REPO : " ${{ vars.GHCR_REPO }}"
154
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
155
- run : |
156
- ./hooks/push
157
- if : ${{ matrix.base_image == 'debian' && env.HAVE_GHCR_LOGIN == 'true' }}
158
-
159
- # Quay.io
160
- - name : Build Debian based images (quay.io)
161
- shell : bash
162
- env :
163
- DOCKER_REPO : " ${{ vars.QUAY_REPO }}"
164
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
165
- run : |
166
- ./hooks/build
167
- if : ${{ matrix.base_image == 'debian' && env.HAVE_QUAY_LOGIN == 'true' }}
168
-
169
- - name : Push Debian based images (quay.io)
170
- shell : bash
171
- env :
172
- DOCKER_REPO : " ${{ vars.QUAY_REPO }}"
173
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}"
174
- run : |
175
- ./hooks/push
176
- if : ${{ matrix.base_image == 'debian' && env.HAVE_QUAY_LOGIN == 'true' }}
177
-
178
- # Alpine
179
-
180
- # Docker Hub
181
- - name : Build Alpine based images (docker.io)
182
- shell : bash
183
- env :
184
- DOCKER_REPO : " ${{ vars.DOCKERHUB_REPO }}"
185
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
186
- run : |
187
- ./hooks/build
188
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
189
-
190
- - name : Push Alpine based images (docker.io)
191
- shell : bash
192
- env :
193
- DOCKER_REPO : " ${{ vars.DOCKERHUB_REPO }}"
194
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
195
- run : |
196
- ./hooks/push
197
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_DOCKERHUB_LOGIN == 'true' }}
198
-
199
- # GitHub Container Registry
200
- - name : Build Alpine based images (ghcr.io)
201
- shell : bash
202
- env :
203
- DOCKER_REPO : " ${{ vars.GHCR_REPO }}"
204
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
205
- run : |
206
- ./hooks/build
207
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_GHCR_LOGIN == 'true' }}
208
-
209
- - name : Push Alpine based images (ghcr.io)
210
- shell : bash
211
- env :
212
- DOCKER_REPO : " ${{ vars.GHCR_REPO }}"
213
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
214
- run : |
215
- ./hooks/push
216
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_GHCR_LOGIN == 'true' }}
217
-
218
- # Quay.io
219
- - name : Build Alpine based images (quay.io)
152
+ - name : Add registry for Quay.io
153
+ if : ${{ env.HAVE_QUAY_LOGIN == 'true' }}
220
154
shell : bash
221
- env :
222
- DOCKER_REPO : " ${{ vars.QUAY_REPO }}"
223
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
224
155
run : |
225
- ./hooks/build
226
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_QUAY_LOGIN == 'true' }}
156
+ echo "CONTAINER_REGISTRIES=${CONTAINER_REGISTRIES:+${CONTAINER_REGISTRIES},}${{ vars.QUAY_REPO }}" | tee -a "${GITHUB_ENV}"
227
157
228
- - name : Push Alpine based images (quay.io)
229
- shell : bash
158
+ - name : Bake ${{ matrix.base_image }} containers
159
+ uses : docker/bake-action@511fde2517761e303af548ec9e0ea74a8a100112 # v4.0.0
230
160
env :
231
- DOCKER_REPO : " ${{ vars.QUAY_REPO }}"
232
- DOCKER_TAG : " ${{steps.vars.outputs.DOCKER_TAG}}-alpine"
233
- run : |
234
- ./hooks/push
235
- if : ${{ matrix.base_image == 'alpine' && env.HAVE_QUAY_LOGIN == 'true' }}
161
+ BASE_TAGS : " ${{ env.BASE_TAGS }}"
162
+ SOURCE_COMMIT : " ${{ env.SOURCE_COMMIT }}"
163
+ SOURCE_VERSION : " ${{ env.SOURCE_VERSION }}"
164
+ SOURCE_REPOSITORY_URL : " ${{ env.SOURCE_REPOSITORY_URL }}"
165
+ CONTAINER_REGISTRIES : " ${{ env.CONTAINER_REGISTRIES }}"
166
+ with :
167
+ pull : true
168
+ push : true
169
+ files : docker/docker-bake.hcl
170
+ targets : " ${{ matrix.base_image }}-multi"
0 commit comments