feat: goreleaser

This commit is contained in:
Carlos Alexandro Becker committed 2018-11-08 13:27:16 -02:00
1 parent b6537bb47b
commit f69e158c8e
3 files changed
+26 -42

No files matched your search

+4 -42
View File
@@ -1,42 +1,4 @@
# 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 -d ./...
# Build a standalone binary
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/server2.status /etc/openvpn_exporter/server.status
# run
EXPOSE 9176
CMD ["/openvpn_exporter", "-openvpn.status_paths", "/etc/openvpn_exporter/server.status"]
FROM scratch
COPY openvpn_exporter /bin/openvpn_exporter
ENTRYPOINT ["/bin/openvpn_exporter"]
CMD [ "-h" ]