OP#176 edit Dockerfile and start.sh
This commit is contained in:
28
Dockerfile
28
Dockerfile
@@ -6,33 +6,37 @@ RUN apk add --no-cache git make gcc musl-dev
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
|
||||
# Fix missing go.sum entries
|
||||
RUN go mod tidy
|
||||
|
||||
# Build (default target = all)
|
||||
RUN make
|
||||
|
||||
# Verify binary exists and is executable — no --version check
|
||||
# Verify binary
|
||||
RUN ls -la postgresql-prometheus-adapter && \
|
||||
./postgresql-prometheus-adapter --help > /dev/null
|
||||
|
||||
|
||||
# ───── Stage 2: Runtime (Alpine = has glibc + loader) ─────
|
||||
# ───── Stage 2: Runtime (Alpine for glibc/loader) ─────
|
||||
FROM alpine:3.20
|
||||
|
||||
# Install only what the binary needs (tiny)
|
||||
RUN apk add --no-cache libc6-compat
|
||||
RUN apk add --no-cache libc6-compat bash # bash for start.sh, libc for binary
|
||||
|
||||
# Copy binary
|
||||
COPY --from=builder /src/postgresql-prometheus-adapter /usr/local/bin/postgresql-prometheus-adapter
|
||||
|
||||
# Make sure it's executable (just in case)
|
||||
RUN chmod +x /usr/local/bin/postgresql-prometheus-adapter
|
||||
|
||||
USER 1001:1001
|
||||
# Copy and make start.sh executable
|
||||
COPY start.sh /usr/local/bin/start.sh
|
||||
RUN chmod +x /usr/local/bin/start.sh
|
||||
|
||||
# Non-root user
|
||||
RUN addgroup -g 1001 -S appgroup && \
|
||||
adduser -S -D -H -u 1001 -h /home/app -s /bin/bash -G appgroup -g appuser appuser
|
||||
USER appuser
|
||||
|
||||
WORKDIR /home/app
|
||||
|
||||
EXPOSE 9201
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD ["wget", "--spider", "-q", "http://127.0.0.1:9201/health"] || exit 1
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:9201/health || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/postgresql-prometheus-adapter"]
|
||||
ENTRYPOINT ["/usr/local/bin/start.sh"]
|
||||
Reference in New Issue
Block a user