diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7331a8..8c9b13a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a71ffd..320871f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/Dockerfile b/Dockerfile index cd191aa..2ec3b34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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