Browse Source
* Revert to amd64 Dockerfile to fix automatic Docker Hub building and add multiarch image separately instead * Change base image for the building stage to alpine and update the golang version to latest * Change the entrypoint path for consistency with base image * Make use of COPY instead of cloning the git repo in the building stage * Add missing default lua-metrics-file argument as it is requiredmaster
Manuel
4 years ago
2 changed files with 33 additions and 19 deletions
@ -1,23 +1,14 @@ |
|||
FROM --platform=$BUILDPLATFORM golang:1.15 AS build |
|||
FROM golang:alpine as build |
|||
|
|||
ARG TARGETOS |
|||
ARG TARGETARCH |
|||
ARG TARGETVARIANT |
|||
|
|||
RUN git clone https://github.com/chr-fritz/fritzbox_exporter.git /go/src/github.com/chr-fritz/fritzbox_exporter |
|||
WORKDIR /go/src/github.com/chr-fritz/fritzbox_exporter |
|||
COPY . /usr/src/fritzbox_exporter |
|||
WORKDIR /usr/src/fritzbox_exporter |
|||
|
|||
RUN go mod download; \ |
|||
case "$TARGETVARIANT" in \ |
|||
v5) export GOARM=5 ;; \ |
|||
v6) export GOARM=6 ;; \ |
|||
v7) export GOARM=7 ;; \ |
|||
esac; \ |
|||
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags '-w -extldflags "-static"' -o fritzbox-exporter . |
|||
|
|||
FROM --platform=$TARGETPLATFORM alpine:latest |
|||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -extldflags "-static"' -o fritzbox-exporter . |
|||
|
|||
FROM alpine:latest |
|||
RUN apk --no-cache add ca-certificates |
|||
COPY --from=build /go/src/github.com/chr-fritz/fritzbox_exporter/fritzbox-exporter /fritzbox-exporter/ |
|||
COPY --from=build /go/src/github.com/chr-fritz/fritzbox_exporter/*.json /etc/fritzbox-exporter/ |
|||
ENTRYPOINT ["/fritzbox-exporter/fritzbox-exporter"] |
|||
CMD ["--metrics-file","/etc/fritzbox-exporter/metrics.json","--listen-address","0.0.0.0:8080"] |
|||
COPY --from=build /usr/src/fritzbox_exporter/fritzbox-exporter /bin/ |
|||
COPY --from=build /usr/src/fritzbox_exporter/*.json /etc/fritzbox-exporter/ |
|||
ENTRYPOINT ["/bin/fritzbox-exporter"] |
|||
CMD ["--metrics-file","/etc/fritzbox-exporter/metrics.json","--lua-metrics-file","/etc/fritzbox-exporter/metrics-lua.json","--listen-address","0.0.0.0:8080"] |
|||
|
@ -0,0 +1,23 @@ |
|||
FROM --platform=$BUILDPLATFORM golang:alpine as build |
|||
|
|||
ARG TARGETOS |
|||
ARG TARGETARCH |
|||
ARG TARGETVARIANT |
|||
|
|||
COPY . /usr/src/fritzbox_exporter |
|||
WORKDIR /usr/src/fritzbox_exporter |
|||
|
|||
RUN go mod download; \ |
|||
case "$TARGETVARIANT" in \ |
|||
v5) export GOARM=5 ;; \ |
|||
v6) export GOARM=6 ;; \ |
|||
v7) export GOARM=7 ;; \ |
|||
esac; \ |
|||
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags '-w -extldflags "-static"' -o fritzbox-exporter . |
|||
|
|||
FROM --platform=$TARGETPLATFORM alpine:latest |
|||
RUN apk --no-cache add ca-certificates |
|||
COPY --from=build /usr/src/fritzbox_exporter/fritzbox-exporter /bin/ |
|||
COPY --from=build /usr/src/fritzbox_exporter/*.json /etc/fritzbox-exporter/ |
|||
ENTRYPOINT ["/bin/fritzbox-exporter"] |
|||
CMD ["--metrics-file","/etc/fritzbox-exporter/metrics.json","--lua-metrics-file","/etc/fritzbox-exporter/metrics-lua.json","--listen-address","0.0.0.0:8080"] |
Loading…
Reference in new issue