-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile
38 lines (32 loc) · 1.2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# syntax=docker/dockerfile:1
FROM golang:1.22-alpine AS builder-env
# Build a self-contained pg_exporter container with a clean environment and no
# dependencies.
#
# build with
#
# docker buildx build -f Dockerfile --tag pg_exporter .
#
WORKDIR /build
COPY go.mod go.sum ./
RUN \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go mod download
COPY . /build
RUN \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -a -o /pg_exporter .
FROM scratch
LABEL org.opencontainers.image.authors="Vonng <[email protected]>, Craig Ringer <[email protected]>" \
org.opencontainers.image.url="https://github.com/Vonng/pg_exporter" \
org.opencontainers.image.source="https://github.com/Vonng/pg_exporter" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="pg_exporter" \
org.opencontainers.image.description="PostgreSQL metrics exporter for Prometheus"
WORKDIR /bin
COPY --from=builder-env /pg_exporter /bin/pg_exporter
COPY pg_exporter.yml /etc/pg_exporter.yml
EXPOSE 9630/tcp
ENTRYPOINT ["/bin/pg_exporter"]