This commit is contained in:
parent
355f2c5819
commit
817f317b03
1 changed files with 11 additions and 3 deletions
14
Dockerfile
14
Dockerfile
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue