forked from kuskoman/logstash-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (22 loc) · 741 Bytes
/
Dockerfile
File metadata and controls
33 lines (22 loc) · 741 Bytes
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
FROM golang:1.22.2-alpine3.19 as build
ARG VERSION \
GIT_COMMIT \
GITHUB_REPO="github.com/kuskoman/logstash-exporter"
WORKDIR /app
RUN grep "nobody:x:65534" /etc/passwd > /app/user
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
-ldflags="-w -s \
-X ${GITHUB_REPO}/config.Version=${VERSION} \
-X ${GITHUB_REPO}/config.GitCommit=${GIT_COMMIT} \
-X ${GITHUB_REPO}/config.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o main cmd/exporter/main.go
FROM scratch as release
COPY --from=build /app/user /etc/passwd
COPY --from=build /app/main /app/main
EXPOSE 9198
USER 65534
ENTRYPOINT ["/app/main"]
ENV EXPORTER_CONFIG_LOCATION=/app/config.yml