Files
renaldybrada 01bc12352a docker ready
2026-02-27 12:38:36 +07:00

37 lines
710 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ================================
# 1⃣ Builder Stage
# ================================
FROM golang:1.25.3-alpine AS builder
WORKDIR /app
# Install git jika pakai private module
RUN apk add --no-cache git
# Cache dependency
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build dari cmd/api
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" \
-o app ./cmd/api
# ================================
# 2⃣ Final Stage (Distroless)
# ================================
FROM gcr.io/distroless/base-debian12
WORKDIR /app
COPY --from=builder /app/app .
# Run as non-root (distroless default user)
USER nonroot:nonroot
EXPOSE 8080
ENTRYPOINT ["/app/app"]