feat: goreleaser
This commit is contained in:
3 files changed
+26
-42
No files matched your search
@@ -1,2 +1,3 @@
|
|||||||
openvpn_exporter
|
openvpn_exporter
|
||||||
.idea
|
.idea
|
||||||
|
dist
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# This is an example goreleaser.yaml file with some sane defaults.
|
||||||
|
# Make sure to check the documentation at http://goreleaser.com
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod download
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
dockers:
|
||||||
|
- image_templates:
|
||||||
|
- "caarlos0/openvpn-exporter:latest"
|
||||||
|
- "caarlos0/openvpn-exporter:{{ .Tag }}"
|
||||||
|
build_flag_templates:
|
||||||
|
- "--label=org.label-schema.schema-version=1.0"
|
||||||
|
- "--label=org.label-schema.version={{ .Version }}"
|
||||||
|
- "--label=org.label-schema.name={{ .ProjectName }}"
|
||||||
+4
-42
@@ -1,42 +1,4 @@
|
|||||||
# BUILD:
|
FROM scratch
|
||||||
# docker build --force-rm=true -t openvpn_exporter .
|
COPY openvpn_exporter /bin/openvpn_exporter
|
||||||
|
ENTRYPOINT ["/bin/openvpn_exporter"]
|
||||||
# RUN:
|
CMD [ "-h" ]
|
||||||
# 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"]
|
|
||||||
Reference in new issue
Block a user