-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve Dockerfile: new golang and cache dependencies in extra layer
- Loading branch information
Showing
1 changed file
with
10 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
FROM golang:1.17-alpine AS builder | ||
FROM golang:1.19.4-alpine AS builder | ||
|
||
WORKDIR /build | ||
COPY . /build/ | ||
|
||
ENV CGO_ENABLED=0 | ||
|
||
# cache dependencies | ||
# from https://github.com/montanaflynn/golang-docker-cache | ||
COPY go.mod go.sum ./ | ||
RUN go mod graph | awk '{if ($1 !~ "@") print $2}' | xargs -r go get | ||
|
||
COPY . ./ | ||
|
||
RUN go build -v . | ||
|
||
FROM busybox | ||
|
||
COPY --from=builder /build/fritzbox_exporter /usr/local/bin/fritzbox_exporter | ||
COPY --from=builder /build/fritzbox_exporter /app/fritzbox_exporter | ||
|
||
EXPOSE 9133 | ||
ENTRYPOINT /usr/local/bin/fritzbox_exporter | ||
ENTRYPOINT /app/fritzbox_exporter |