OP#176 edit Dockerfilet
This commit is contained in:
44
Dockerfile
44
Dockerfile
@@ -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
|
# Install build tools
|
||||||
RUN make
|
RUN apk add --no-cache git make gcc musl-dev
|
||||||
RUN make container
|
|
||||||
|
|
||||||
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"]
|
||||||
Reference in New Issue
Block a user