Skip to content

Commit

Permalink
Add docker/setup-buildx-action to build_docker job
Browse files Browse the repository at this point in the history
  • Loading branch information
manastyretskyi authored and ARolek committed Aug 14, 2023
1 parent 7e316eb commit 096b5d9
Showing 1 changed file with 45 additions and 19 deletions.
64 changes: 45 additions & 19 deletions .github/workflows/on_release_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,42 +161,68 @@ jobs:
env:
DOCKERHUB_ORG: gospatial
DOCKERHUB_REPO: tegola
BUILD_ARGS: |
BUILDPKG=${BUILD_PKG}
VER=${VERSION}
BRANCH=${GIT_BRANCH}
REVISION=${GIT_REVISION}
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Setup env
uses: ./.github/actions/tegola-setup-env
with:
ui: true

- name: Build and tag Docker container
# Buildx can only output single-platform result image to docker
# so for testing purposes we are building only for linux/amd64
# Later when we publish the image we build for linux/amd64 and linux/arm64
# Note that linux/amd64 is cached, so when we build images for publishing
# we are not rebuilding linux/amd64
- name: Build docker image for testing
uses: docker/build-push-action@v4
with:
context: .
load: true
platforms: linux/amd64
build-args: ${{ env.BUILD_ARGS }}
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}

- name: Test image build
run: |
docker build -t tegola --build-arg BUILDPKG=${BUILD_PKG} --build-arg VER=${VERSION} --build-arg BRANCH=${GIT_BRANCH} --build-arg REVISION=${GIT_REVISION} .
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION}
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:latest
docker tag tegola:latest ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:edge
docker run --rm tegola version
docker run --rm ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION} version
- name: Publish Docker edge container
if: github.ref == env.DEFAULT_BRANCH_REF
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USER} --password-stdin
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:edge
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:edge
platforms: linux/amd64,linux/arm64
build-args: ${{ env.BUILD_ARGS }}

- name: Publish Docker container
if: github.event_name == 'release'
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
run: |
echo ${DOCKERHUB_PASSWORD} | docker login -u ${DOCKERHUB_USER} --password-stdin
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION}
docker push ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:latest
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }},${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:latest
platforms: linux/amd64,linux/arm64
build-args: ${{ env.BUILD_ARGS }}

build_windows:
name: Build for Windows
Expand Down

0 comments on commit 096b5d9

Please sign in to comment.