Update docker file

This commit is contained in:
Ivaylo Korakov 2019-10-31 18:22:22 +01:00
parent 0a237f860d
commit aa111672d4

View File

@ -1,14 +1,26 @@
FROM golang:1.8
# Builder stage to
FROM golang:1.12 as builder
# Add the project in the image
ADD . /go/src/github.com/kumina/postfix_exporter
WORKDIR /go/src/github.com/kumina/postfix_exporter
RUN apt-get update -qq && apt-get install -qqy \
# Install needed dependencies for the build
RUN apt-get update -q && apt-get install -qy \
build-essential \
libsystemd-dev
RUN go get -v ./...
RUN go build
# Get dependencies and build the static binary
RUN go get -d ./...
RUN go build -a -tags static_all
# Real image
FROM debian:latest
EXPOSE 9154
WORKDIR /
COPY --from=0 /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
# Copy the binary from the build image to the real one
COPY --from=builder /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
ENTRYPOINT ["/postfix_exporter"]