# Stage 1: Build the Go binary FROM golang:1.22-alpine AS builder WORKDIR /app COPY go.mod ./ COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o server . # Stage 2: Ultra-lightweight runtime container FROM alpine:3.19 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app # Copy binary and static front-end assets COPY --from=builder /app/server /app/server COPY --from=builder /app/public /app/public COPY --from=builder /app/appsettings.json /app/appsettings.default.json COPY start.sh /app/start.sh RUN chmod +x /app/start.sh EXPOSE 8080 ENTRYPOINT ["/app/start.sh"]