Skip to content

Commit 096b5d9

Browse files
manastyretskyiARolek
authored andcommitted
Add docker/setup-buildx-action to build_docker job
1 parent 7e316eb commit 096b5d9

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

.github/workflows/on_release_publish.yml

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,42 +161,68 @@ jobs:
161161
env:
162162
DOCKERHUB_ORG: gospatial
163163
DOCKERHUB_REPO: tegola
164+
BUILD_ARGS: |
165+
BUILDPKG=${BUILD_PKG}
166+
VER=${VERSION}
167+
BRANCH=${GIT_BRANCH}
168+
REVISION=${GIT_REVISION}
164169
165170
steps:
166171
- name: Check out code
167172
uses: actions/checkout@v3
168173

174+
- name: Set up QEMU
175+
uses: docker/setup-qemu-action@v2
176+
177+
- name: Set up Docker Buildx
178+
uses: docker/setup-buildx-action@v2
179+
180+
- name: Login to Docker Hub
181+
uses: docker/login-action@v2
182+
with:
183+
username: ${{ secrets.DOCKERHUB_USER }}
184+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
185+
169186
- name: Setup env
170187
uses: ./.github/actions/tegola-setup-env
171188
with:
172189
ui: true
173190

174-
- name: Build and tag Docker container
191+
# Buildx can only output single-platform result image to docker
192+
# so for testing purposes we are building only for linux/amd64
193+
# Later when we publish the image we build for linux/amd64 and linux/arm64
194+
# Note that linux/amd64 is cached, so when we build images for publishing
195+
# we are not rebuilding linux/amd64
196+
- name: Build docker image for testing
197+
uses: docker/build-push-action@v4
198+
with:
199+
context: .
200+
load: true
201+
platforms: linux/amd64
202+
build-args: ${{ env.BUILD_ARGS }}
203+
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}
204+
205+
- name: Test image build
175206
run: |
176-
docker build -t tegola --build-arg BUILDPKG=${BUILD_PKG} --build-arg VER=${VERSION} --build-arg BRANCH=${GIT_BRANCH} --build-arg REVISION=${GIT_REVISION} .
177-
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION}
178-
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:latest
179-
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:edge
180-
docker run --rm tegola version
207+
docker run --rm ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION} version
181208
182209
- name: Publish Docker edge container
183210
if: github.ref == env.DEFAULT_BRANCH_REF
184-
env:
185-
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
186-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
187-
run: |
188-
echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USER} --password-stdin
189-
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:edge
211+
uses: docker/build-push-action@v4
212+
with:
213+
push: true
214+
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:edge
215+
platforms: linux/amd64,linux/arm64
216+
build-args: ${{ env.BUILD_ARGS }}
190217

191218
- name: Publish Docker container
192219
if: github.event_name == 'release'
193-
env:
194-
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
195-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
196-
run: |
197-
echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USER} --password-stdin
198-
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION}
199-
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:latest
220+
uses: docker/build-push-action@v4
221+
with:
222+
push: true
223+
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }},${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:latest
224+
platforms: linux/amd64,linux/arm64
225+
build-args: ${{ env.BUILD_ARGS }}
200226

201227
build_windows:
202228
name: Build for Windows

0 commit comments

Comments
 (0)