Multi arch
All checks were successful
Docker Deploy / build-and-push (push) Successful in 1m5s

This commit is contained in:
Atridad Lahiji 2025-02-08 02:17:20 -06:00
parent 355f2c5819
commit 817f317b03
Signed by: atridad
SSH key fingerprint: SHA256:LGomp8Opq0jz+7kbwNcdfTcuaLRb5Nh0k5AchDDb438

View file

@ -1,4 +1,4 @@
FROM golang:1.23.2-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.2-alpine AS builder
WORKDIR /app
@ -19,14 +19,22 @@ RUN mkdir -p /app/public/css
# Generate assets and build with optimizations
SHELL ["/bin/bash", "-c"]
# Platform-specific builds
ARG TARGETPLATFORM
RUN cd /app && make generate && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
case "${TARGETPLATFORM}" in \
"linux/amd64") GOARCH=amd64 ;; \
"linux/arm64") GOARCH=arm64 ;; \
*) GOARCH=amd64 ;; \
esac && \
CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build \
-ldflags='-s -w -extldflags "-static"' \
-tags netgo,osusergo \
-o /go/bin/app
# Final stage
FROM scratch
FROM --platform=$TARGETPLATFORM scratch
# Copy static files and assets
COPY --from=builder /app/public/css/styles.css /public/css/styles.css