-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
53 lines (35 loc) · 904 Bytes
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# syntax=docker/dockerfile:1
#
# BUILD
#
ARG GOVERSION=1.22
FROM docker.io/golang:${GOVERSION}-alpine AS build
RUN apk add --update --no-cache ca-certificates
RUN adduser \
--disabled-password \
--shell /sbin/nologin \
--home /nonexistent \
--no-create-home \
--gecos "" \
user
WORKDIR /build
COPY go.mod go.sum /build/
RUN go mod download
COPY . /build/
ARG GOOS=linux
ARG GOARCH=amd64
ARG VERSION=v0.0.0+unknown
RUN GOOS=${GOOS} GOARCH=${GOARCH} go build \
-ldflags "-X 'main.version=${VERSION}' -s -w" \
-o /bin/gitlab-exporter
#
# RUN
#
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group
COPY --from=build /bin/gitlab-exporter /bin/gitlab-exporter
USER user:user
ENTRYPOINT [ "/bin/gitlab-exporter" ]
CMD [ "--help" ]