976f5238f8
- internal .env loader (real env wins) + strictly validated config struct - ULID package: 48-bit ms timestamp + 80-bit crypto randomness, sortable - HTTP server with recovery/request-id/trusted-proxy/access-log middleware - /healthz, /readyz (pluggable checkers), /metricsz (counter registry) - multi-stage Dockerfile (alpine, non-root) + compose with healthchecks, app bound to 127.0.0.1:8787, mongo unpublished, graceful 15s shutdown Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
19 lines
497 B
Docker
19 lines
497 B
Docker
# --- build stage ---
|
|
FROM golang:1.26-alpine AS build
|
|
WORKDIR /src
|
|
COPY go.* ./
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/app ./cmd/app
|
|
|
|
# --- runtime stage ---
|
|
FROM alpine:3.21
|
|
RUN apk add --no-cache ca-certificates && \
|
|
addgroup -S app && adduser -S -G app app
|
|
USER app
|
|
WORKDIR /srv
|
|
COPY --from=build /out/app /usr/local/bin/app
|
|
EXPOSE 8787
|
|
# busybox wget ships with alpine; used by the compose healthcheck
|
|
ENTRYPOINT ["/usr/local/bin/app"]
|