From 7b4c5b594b94ceea846b135b477287eb87946d6f Mon Sep 17 00:00:00 2001 From: 12ww1160 Date: Tue, 2 Dec 2025 15:09:57 +0100 Subject: [PATCH] OP#176 edit Dockerfile make step --- Dockerfile | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07fcc15..890e05a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,31 @@ -# ───── Stage 1: Build the Go binary ───── +# ───── Stage 1: Build the adapter binary ───── FROM golang:1.22-alpine AS builder -LABEL 12ww1160 <12ww1160@confdroid.com> - -# Install build tools RUN apk add --no-cache git make gcc musl-dev -# Workdir = your local source WORKDIR /src + +# Copy your local source (you already have it) COPY . . -# Build exactly like the original Makefile does -RUN make binary +# Build the binary — just "make" is enough (default target = all) +RUN make -# Verify it works -RUN /src/postgresql-prometheus-adapter --help +# Verify it was built +RUN ls -la postgresql-prometheus-adapter && \ + ./postgresql-prometheus-adapter --version -# ───── Stage 2: Tiny runtime image ───── -# Option A: Alpine (has glibc, easy debugging) -# FROM alpine:3.20 - -# Option B: Distroless (smallest & most secure) ← recommended +# ───── Stage 2: Tiny, secure, non-root runtime ───── FROM gcr.io/distroless/static-debian12 -# Copy only the binary COPY --from=builder /src/postgresql-prometheus-adapter /usr/local/bin/postgresql-prometheus-adapter -# Optional: copy CA certificates if you use HTTPS to reach the adapter -# (distroless already includes them) - -# Non-root user (same UID/GID as original Crunchy image) -USER 1001 +USER 1001:1001 EXPOSE 9201 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD ["wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9201/health"] || exit 1 + CMD ["/usr/local/bin/postgresql-prometheus-adapter", "--health"] || exit 1 ENTRYPOINT ["/usr/local/bin/postgresql-prometheus-adapter"] \ No newline at end of file