Update Dockerfile to use Go 1.11 with modules

This commit is contained in:
Julian Kornberger 2019-01-28 01:26:44 +01:00
parent acf7a97917
commit 99db0017f8

View File

@ -1,14 +1,23 @@
FROM golang:1.8
ADD . /go/src/github.com/kumina/postfix_exporter
WORKDIR /go/src/github.com/kumina/postfix_exporter
FROM golang:1.11 AS builder
WORKDIR /src
# avoid downloading the dependencies on succesive builds
RUN apt-get update -qq && apt-get install -qqy \
build-essential \
libsystemd-dev
RUN go get -v ./...
RUN go build
COPY go.mod go.sum ./
RUN go mod download
RUN go mod verify
COPY . .
# Force the go compiler to use modules
ENV GO111MODULE=on
RUN go build -o /bin/postfix_exporter
FROM debian:latest
EXPOSE 9154
WORKDIR /
COPY --from=0 /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
ENTRYPOINT ["/postfix_exporter"]
COPY --from=builder /bin/postfix_exporter /bin/
ENTRYPOINT ["/bin/postfix_exporter"]