-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpostgres_exporter.dockerfile
More file actions
74 lines (60 loc) · 2.6 KB
/
Copy pathpostgres_exporter.dockerfile
File metadata and controls
74 lines (60 loc) · 2.6 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ╔═════════════════════════════════════════════════════╗
# ║ SETUP ║
# ╚═════════════════════════════════════════════════════╝
# GLOBAL
ARG APP_UID=1000 \
APP_GID=1000 \
APP_GO_VERSION=0
# APP
ARG BUILD_SRC=https://github.com/prometheus-community/postgres_exporter.git \
BUILD_ROOT=/go/postgres_exporter \
BUILD_BIN=/postgres_exporter
# :: FOREIGN IMAGES
FROM 11notes/distroless AS distroless
# ╔═════════════════════════════════════════════════════╗
# ║ BUILD ║
# ╚═════════════════════════════════════════════════════╝
# :: GOVC
FROM 11notes/go:${APP_GO_VERSION} AS build
ARG APP_VERSION \
BUILD_SRC \
BUILD_ROOT \
BUILD_BIN
RUN set -ex; \
eleven git clone ${BUILD_SRC} v${APP_VERSION};
RUN set -ex; \
cd ${BUILD_ROOT}; \
go build -ldflags="-extldflags=-static -X github.com/prometheus/common/version.Version=${APP_VERSION}" -o ${BUILD_BIN} ./cmd/postgres_exporter;
RUN set -ex; \
${BUILD_BIN} --version 2>&1 | grep -q "${APP_VERSION}";
RUN set -ex; \
eleven distroless ${BUILD_BIN};
# ╔═════════════════════════════════════════════════════╗
# ║ IMAGE ║
# ╚═════════════════════════════════════════════════════╝
# :: HEADER
FROM scratch
# :: default arguments
ARG TARGETPLATFORM \
TARGETOS \
TARGETARCH \
TARGETVARIANT \
APP_IMAGE \
APP_NAME \
APP_VERSION \
APP_ROOT \
APP_UID \
APP_GID \
APP_NO_CACHE
# :: default environment
ENV APP_IMAGE=${APP_IMAGE} \
APP_NAME=${APP_NAME} \
APP_VERSION=${APP_VERSION} \
APP_ROOT=${APP_ROOT}
# :: multi-stage
COPY --from=distroless / /
COPY --from=build ${APP_ROOT}/ /
# :: EXECUTE
USER ${APP_UID}:${APP_GID}
ENTRYPOINT ["/usr/local/bin/postgres_exporter"]
CMD ["--version"]