-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathDockerfile
31 lines (19 loc) · 847 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
FROM golang:1.20-alpine as build
ARG TARGETPLATFORM
RUN echo "Building for ${TARGETPLATFORM}"
WORKDIR /go/src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -a -ldflags '-extldflags "-s -w -static"' -o /squid-exporter .
FROM gcr.io/distroless/static:nonroot as final
LABEL org.opencontainers.image.title="Squid Exporter"
LABEL org.opencontainers.image.description="This is a Docker image for Squid Prometheus Exporter."
LABEL org.opencontainers.image.source="https://github.com/boynux/squid-exporter/"
LABEL org.opencontainers.image.licenses="MIT"
ENV SQUID_EXPORTER_LISTEN="0.0.0.0:9301"
COPY --from=build /squid-exporter /usr/local/bin/squid-exporter
# Allow /etc/hosts to be used for DNS
COPY --from=build /etc/nsswitch.conf /etc/nsswitch.conf
EXPOSE 9301
ENTRYPOINT ["/usr/local/bin/squid-exporter"]