Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARM support for Docker build #114

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading