2019-10-31 17:22:22 +00:00
|
|
|
# Builder stage to
|
2020-02-12 12:41:29 +00:00
|
|
|
FROM golang:1.13 as builder
|
2019-10-31 17:22:22 +00:00
|
|
|
|
|
|
|
# Add the project in the image
|
2018-11-04 01:57:56 +00:00
|
|
|
ADD . /go/src/github.com/kumina/postfix_exporter
|
|
|
|
WORKDIR /go/src/github.com/kumina/postfix_exporter
|
2019-10-31 17:22:22 +00:00
|
|
|
|
|
|
|
# Install needed dependencies for the build
|
|
|
|
RUN apt-get update -q && apt-get install -qy \
|
2018-11-04 01:57:56 +00:00
|
|
|
build-essential \
|
|
|
|
libsystemd-dev
|
|
|
|
|
2019-10-31 17:22:22 +00:00
|
|
|
# Get dependencies and build the static binary
|
2020-02-12 12:41:29 +00:00
|
|
|
RUN go test
|
2019-10-31 17:22:22 +00:00
|
|
|
RUN go build -a -tags static_all
|
|
|
|
|
|
|
|
# Real image
|
2018-11-04 01:57:56 +00:00
|
|
|
FROM debian:latest
|
2019-10-31 17:22:22 +00:00
|
|
|
|
2018-11-04 01:57:56 +00:00
|
|
|
EXPOSE 9154
|
|
|
|
WORKDIR /
|
2019-10-31 17:22:22 +00:00
|
|
|
|
|
|
|
# Copy the binary from the build image to the real one
|
|
|
|
COPY --from=builder /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
|
|
|
|
|
2018-11-04 01:57:56 +00:00
|
|
|
ENTRYPOINT ["/postfix_exporter"]
|