Skip to content

Commit

Permalink
Add ARM support for Docker build (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoshet authored Nov 19, 2024
1 parent 4c76f08 commit 0db6dc7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
tags:
- 'v*.*.*'
pull_request:

jobs:
docker:
Expand All @@ -16,11 +17,20 @@ jobs:
VERSION: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build image
run: docker build -t "$IMAGE_REPOSITORY" .
run: |
docker buildx create \
--name multibuilder \
--platform linux/amd64,linux/arm64 \
--bootstrap --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t "$IMAGE_REPOSITORY" .
- name: Build k6 binary
run: |
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/xk6" \
Expand All @@ -41,8 +51,10 @@ jobs:
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:master"
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:master"
docker push "ghcr.io/${IMAGE_REPOSITORY}:master"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:master \
-t "ghcr.io/${IMAGE_REPOSITORY}:master" .
- name: Publish tagged version image to ghcr.io
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
Expand All @@ -54,8 +66,10 @@ jobs:
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:latest"
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:latest"
docker push "ghcr.io/${IMAGE_REPOSITORY}:latest"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:latest \
-t "ghcr.io/${IMAGE_REPOSITORY}:latest" .
fi
- name: Log into Docker Hub
Expand All @@ -67,8 +81,10 @@ jobs:
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as ${IMAGE_REPOSITORY}:master"
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:master"
docker push "${IMAGE_REPOSITORY}:master"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:master \
-t "ghcr.io/${IMAGE_REPOSITORY}:master" .
- name: Publish tagged version image to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
Expand All @@ -80,6 +96,8 @@ jobs:
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as ${IMAGE_REPOSITORY}:latest"
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:latest"
docker push "${IMAGE_REPOSITORY}:latest"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:latest \
-t "ghcr.io/${IMAGE_REPOSITORY}:latest" .
fi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

ARG GO_VERSION=1.22.7
ARG VARIANT=alpine3.20
FROM golang:${GO_VERSION}-${VARIANT} as builder
FROM golang:${GO_VERSION}-${VARIANT} AS builder

WORKDIR /build

Expand Down

0 comments on commit 0db6dc7

Please sign in to comment.