netatmo-exporter/Dockerfile

32 lines
684 B
Docker
Raw Normal View History

2018-09-01 22:22:04 +00:00
FROM golang:1 AS builder
RUN apt-get update && apt-get install -y upx
2018-10-27 14:46:37 +00:00
WORKDIR /build
2018-09-01 22:22:04 +00:00
ENV LD_FLAGS="-w"
ENV CGO_ENABLED=0
2018-10-27 14:46:37 +00:00
COPY go.mod go.sum /build/
RUN go mod download
RUN go mod verify
COPY . /build/
2018-09-01 22:22:04 +00:00
RUN echo "-- TEST" \
2018-10-27 14:46:37 +00:00
&& go test -cover ./... \
2018-09-01 22:22:04 +00:00
&& echo "-- BUILD" \
&& go install -tags netgo -ldflags "${LD_FLAGS}" . \
&& echo "-- PACK" \
&& upx -9 /go/bin/netatmo-exporter
FROM busybox
LABEL maintainer="Robert Jacob <xperimental@solidproject.de>"
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /go/bin/netatmo-exporter /bin/netatmo-exporter
USER nobody
EXPOSE 9210
ENTRYPOINT ["/bin/netatmo-exporter"]