OP#176 edit Dockerfilet

This commit is contained in:
2025-12-02 15:00:57 +01:00
parent 93ca9e815e
commit 2417f095b3

View File

@@ -1,11 +1,41 @@
FROM centos:7
# ───── Stage 1: Build the Go binary ─────
FROM golang:1.22-alpine AS builder
MAINTAINER 12ww1160 <arne@confdroid.com>
LABEL 12ww1160 <12ww1160@confdroid.com>
# Build the binary
RUN make
RUN make container
# Install build tools
RUN apk add --no-cache git make gcc musl-dev
COPY start.sh /
# Workdir = your local source
WORKDIR /src
COPY . .
ENTRYPOINT ["/start.sh"]
# Build exactly like the original Makefile does
RUN make binary
# Verify it works
RUN /src/postgresql-prometheus-adapter --help
# ───── Stage 2: Tiny runtime image ─────
# Option A: Alpine (has glibc, easy debugging)
# FROM alpine:3.20
# Option B: Distroless (smallest & most secure) ← recommended
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
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
ENTRYPOINT ["/usr/local/bin/postgresql-prometheus-adapter"]