# --- 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"]
