Skip to content

Commit

Permalink
improve Dockerfile: new golang and cache dependencies in extra layer
Browse files Browse the repository at this point in the history
  • Loading branch information
ndecker committed Dec 12, 2022
1 parent 62d8380 commit 650faef
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
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

0 comments on commit 650faef

Please sign in to comment.