34 lines
849 B
Docker
34 lines
849 B
Docker
# ───── Stage 1: Build the adapter binary ─────
|
|
FROM golang:1.22-alpine AS builder
|
|
|
|
RUN apk add --no-cache git make gcc musl-dev
|
|
|
|
WORKDIR /src
|
|
|
|
# Copy your local source (you already have it)
|
|
COPY . .
|
|
|
|
# fix go mod
|
|
RUN go mod tidy
|
|
|
|
# Build the binary
|
|
RUN make
|
|
|
|
# Verify it was built
|
|
RUN ls -la postgresql-prometheus-adapter && \
|
|
./postgresql-prometheus-adapter --version
|
|
|
|
|
|
# ───── Stage 2: Tiny, secure, non-root runtime ─────
|
|
FROM gcr.io/distroless/static-debian12
|
|
|
|
COPY --from=builder /src/postgresql-prometheus-adapter /usr/local/bin/postgresql-prometheus-adapter
|
|
|
|
USER 1001:1001
|
|
|
|
EXPOSE 9201
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD ["/usr/local/bin/postgresql-prometheus-adapter", "--health"] || exit 1
|
|
|
|
ENTRYPOINT ["/usr/local/bin/postgresql-prometheus-adapter"] |