Build a static executable, from scratch container
ContainerImages/local_exporter/pipeline/head This commit looks good
Details
ContainerImages/local_exporter/pipeline/head This commit looks good
Details
This reduces the size of the container image from 150 MB to 10 MB.main
parent
14bde2094e
commit
2895e12476
|
@ -1,12 +1,17 @@
|
||||||
FROM docker.io/library/golang:1.21 AS build
|
FROM docker.io/library/golang:1.21-alpine AS build
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/var/cache \
|
||||||
|
apk add \
|
||||||
|
git \
|
||||||
|
&& :
|
||||||
|
|
||||||
RUN go install github.com/lucab/local_exporter@latest
|
RUN go install github.com/lucab/local_exporter@latest
|
||||||
|
|
||||||
|
|
||||||
FROM registry.fedoraproject.org/fedora-minimal:38
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=build /go/bin/local_exporter /usr/local/bin/local_exporter
|
COPY --from=build /go/bin/local_exporter /local_exporter
|
||||||
|
|
||||||
ENTRYPOINT ["local_exporter"]
|
ENTRYPOINT ["/local_exporter"]
|
||||||
|
|
||||||
USER 252:252
|
USER 252:252
|
||||||
|
|
Loading…
Reference in New Issue