-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and optimize generator Docker image building (#1045)
* Fix Docker image of generator always pointing to latest tag * new `REPO_TAG` variable can be used to specify the tag/branch to use for a build * the Makefile default is to use the branch of the current repository `HEAD` * the Dockerfile default (if building manually with Docker) is `main` * updated CircleCI configuration to apply the correct `REPO_TAG` values Signed-off-by: Hugo Hromic <[email protected]> * Optimize Docker image of generator * use multi-stage build to reduce final image size * ensure to use the same Debian version (`bookworm`) for the builder and final images * use `--no-install-recommends` to reduce unnecessary dependency downloads * removed unnecessary `unzip` dependency in the image * use modern syntax (using equal sign) for `ENV` Dockerfile directive Signed-off-by: Hugo Hromic <[email protected]> --------- Signed-off-by: Hugo Hromic <[email protected]>
- Loading branch information
Showing
3 changed files
with
24 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
FROM golang:latest | ||
FROM golang:bookworm AS builder | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y libsnmp-dev unzip && \ | ||
go install github.com/prometheus/snmp_exporter/generator@latest | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends libsnmp-dev | ||
|
||
ARG REPO_TAG=main | ||
RUN go install github.com/prometheus/snmp_exporter/generator@"$REPO_TAG" | ||
|
||
FROM debian:bookworm-slim | ||
|
||
WORKDIR "/opt" | ||
|
||
ENTRYPOINT ["/go/bin/generator"] | ||
ENTRYPOINT ["/bin/generator"] | ||
|
||
ENV MIBDIRS mibs | ||
ENV MIBDIRS=mibs | ||
|
||
CMD ["generate"] | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends libsnmp40 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /go/bin/generator /bin/generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters