forked from shrikantpatnaik/openvpn_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (34 loc) · 1.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# BUILD:
# docker build --force-rm=true -t openvpn_exporter .
# RUN:
# docker run -it -p 9176:9176 -v /path/to/openvpn_server.status:/etc/openvpn_exporter/server.status openvpn_exporter
FROM golang as builder
RUN mkdir /app
RUN mkdir /go/src/app
ADD . /go/src/app
WORKDIR /go/src/app
# Go dep
RUN go get -u github.com/prometheus/client_golang/prometheus && \
go get -u github.com/prometheus/client_golang/prometheus/promhttp && \
go get -u github.com/shrikantpatnaik/go-openvpn-status
# Build
RUN set -ex && \
CGO_ENABLED=0 go build \
-tags netgo \
-o /app/openvpn_exporter \
-v -a \
-ldflags '-extldflags "-static"' && \
ls
# Create the second stage with a basic image.
# this will drop any previous
# stages (defined as `FROM <some_image> as <some_name>`)
# allowing us to start with a fat build image and end up with
# a very small runtime image.
FROM busybox
# add compiled binary
COPY --from=builder /app/openvpn_exporter /openvpn_exporter
# add a default file to be processed
ADD examples/server.status /etc/openvpn_exporter/
# run
EXPOSE 9176
CMD ["/openvpn_exporter", "--openvpn.status_path=/etc/openvpn_exporter/server.status"]