# =========================
# Build stage
# =========================
FROM golang:1.25.5-alpine AS builder

WORKDIR /app

COPY backend/go.mod backend/go.sum ./
RUN go mod download

COPY backend/ ./

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -o server ./cmd/server


# =========================
# Runtime stage
# =========================
FROM gcr.io/distroless/base-debian12

WORKDIR /app

COPY --from=builder /app/server ./server

EXPOSE 8081

USER nonroot:nonroot
ENTRYPOINT ["./server"]
