Skip to content

Commit aa11167

Browse files
author
Ivaylo Korakov
committed
Update docker file
1 parent 0a237f8 commit aa11167

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Dockerfile

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
FROM golang:1.8
1+
# Builder stage to
2+
FROM golang:1.12 as builder
3+
4+
# Add the project in the image
25
ADD . /go/src/github.com/kumina/postfix_exporter
36
WORKDIR /go/src/github.com/kumina/postfix_exporter
4-
RUN apt-get update -qq && apt-get install -qqy \
7+
8+
# Install needed dependencies for the build
9+
RUN apt-get update -q && apt-get install -qy \
510
build-essential \
611
libsystemd-dev
7-
RUN go get -v ./...
8-
RUN go build
912

13+
# Get dependencies and build the static binary
14+
RUN go get -d ./...
15+
RUN go build -a -tags static_all
16+
17+
# Real image
1018
FROM debian:latest
19+
1120
EXPOSE 9154
1221
WORKDIR /
13-
COPY --from=0 /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
22+
23+
# Copy the binary from the build image to the real one
24+
COPY --from=builder /go/src/github.com/kumina/postfix_exporter/postfix_exporter .
25+
1426
ENTRYPOINT ["/postfix_exporter"]

0 commit comments

Comments
 (0)