-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (29 loc) · 810 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
ARG GOLANG_VERSION=1.23.3
ARG PROJECT="fly-exporter"
ARG COMMIT
ARG VERSION
ARG TARGETOS
ARG TARGETARCH
FROM --platform=${TARGETARCH} docker.io/golang:${GOLANG_VERSION} AS build
ARG PROJECT
WORKDIR /${PROJECT}
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY main.go ./
COPY collector ./collector
COPY terminal ./terminal
ARG VERSION
ARG COMMIT
ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build \
-ldflags "-X main.OSVersion=${VERSION} -X main.GitCommit=${COMMIT}" \
-a -installsuffix cgo \
-o /bin/exporter \
./main.go
FROM --platform=${TARGETARCH} gcr.io/distroless/static
LABEL org.opencontainers.image.source=https://github.com/DazWilkin/fly-exporter
COPY --from=build /bin/exporter /
ENTRYPOINT ["/exporter"]