Build and publish cross-platform Docker images

This commit is contained in:
Tobias Gesellchen
2026-02-26 08:43:35 +01:00
parent 53184a6bca
commit 71fd9c1531
3 changed files with 12 additions and 2 deletions
+1
View File
@@ -253,6 +253,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+1
View File
@@ -515,6 +515,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+10 -2
View File
@@ -1,5 +1,9 @@
# Build stage
FROM golang:1.26.0-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.26.0-alpine AS builder
ARG TARGETARCH=amd64
ARG TARGETOS=linux
ARG TARGETVARIANT=
WORKDIR /app
@@ -11,7 +15,11 @@ RUN go mod download
COPY . .
# Build the soundtouch-service
RUN CGO_ENABLED=0 GOOS=linux go build -o /soundtouch-service ./cmd/soundtouch-service
RUN if [ "${TARGETARCH}" = "arm" ] && [ -n "${TARGETVARIANT}" ]; then \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} go build -o /soundtouch-service ./cmd/soundtouch-service; \
else \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /soundtouch-service ./cmd/soundtouch-service; \
fi
# Final stage
FROM alpine:3.23