feat: Publish multi-arch docker image (amd64 and arm64) (#1862)

* add arm64 to goreleaser
This commit is contained in:
Richard Hillmann
2023-05-04 09:11:47 +02:00
committed by GitHub
parent 7c3e3a0999
commit e35007b3a2
4 changed files with 50 additions and 17 deletions
+13 -10
View File
@@ -8,27 +8,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- 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
with:
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push canary tag
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{github.sha}}
tags: gomods/athens:canary
push: true
- name: Set Short SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push commit tag
- name: Build and push images
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{github.sha}}
tags: gomods/athens-dev:${{ steps.vars.outputs.sha_short }}
build-args: VERSION=${{ github.sha }}
tags: gomods/athens:canary,gomods/athens-dev:${{ steps.vars.outputs.sha_short }}
push: true
platforms: linux/amd64,linux/arm64
+22 -2
View File
@@ -8,17 +8,37 @@ jobs:
runs-on: ubuntu-latest
steps:
- 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
with:
platforms: linux/amd64,linux/arm64
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push latest tag
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
gomods/athens
tags: |
type=raw,value=${{ github.ref_name }}
type=raw,value=latest
- name: Build and push images
uses: docker/build-push-action@v4
with:
file: cmd/proxy/Dockerfile
build-args: VERSION=${{ github.ref_name }}
tags: gomods/athens:latest,gomods/athens:${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
platforms: linux/amd64,linux/arm64
+1
View File
@@ -12,6 +12,7 @@ builds:
- darwin
goarch:
- amd64
- arm64
main: cmd/proxy/main.go
binary: athens
ldflags:
+14 -5
View File
@@ -8,15 +8,24 @@
ARG GOLANG_VERSION=1.20
ARG ALPINE_VERSION=3.17
FROM golang:${GOLANG_VERSION}-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:${GOLANG_VERSION}-alpine AS builder
ARG VERSION="unset" \
TARGETARCH
ENV GOARCH=${TARGETARCH} \
GO111MODULE=on \
CGO_ENABLED=0 \
GOPROXY="https://proxy.golang.org"
WORKDIR $GOPATH/src/github.com/gomods/athens
COPY . .
ARG VERSION="unset"
RUN DATE="$(date -u +%Y-%m-%d-%H:%M:%S-%Z)" && GO111MODULE=on CGO_ENABLED=0 GOPROXY="https://proxy.golang.org" go build -ldflags "-X github.com/gomods/athens/pkg/build.version=$VERSION -X github.com/gomods/athens/pkg/build.buildDate=$DATE -s -w" -o /bin/athens-proxy ./cmd/proxy
RUN DATE="$(date -u +%Y-%m-%d-%H:%M:%S-%Z)" && \
go build \
-ldflags "-X github.com/gomods/athens/pkg/build.version=$VERSION -X github.com/gomods/athens/pkg/build.buildDate=$DATE -s -w" \
-o /bin/athens-proxy ./cmd/proxy
FROM alpine:${ALPINE_VERSION}
@@ -30,7 +39,7 @@ RUN chmod 644 /config/config.toml
# Add tini, see https://github.com/gomods/athens/issues/1155 for details.
RUN apk add --update git git-lfs mercurial openssh-client subversion procps fossil tini && \
mkdir -p /usr/local/go
mkdir -p /usr/local/go
ARG USER=athens
RUN adduser -D -h /home/$USER $USER