# kora_mobile_api — multi-stage build (pure Go, CGO disabled)
FROM golang:1.22-alpine AS build
WORKDIR /app

# go.mod + go.sum are committed; `go mod tidy` is a no-op safety net that
# also regenerates go.sum if it ever drifts.
COPY . .
RUN go mod tidy && \
    CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /kora_mobile_api ./cmd/api

# ── Runtime ────────────────────────────────────────────────────────────────
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata ttf-dejavu wget
WORKDIR /app
COPY --from=build /kora_mobile_api /app/kora_mobile_api

ENV PORT=8080
EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD wget -qO- http://localhost:8080/healthz || exit 1

ENTRYPOINT ["/app/kora_mobile_api"]
