From dc69eba3b7e6f2226eace4c1ef3e8626c9c52ace Mon Sep 17 00:00:00 2001 From: Oleg Stepura Date: Thu, 22 Oct 2020 21:51:42 +0200 Subject: [PATCH] Use builder to build binary Uses same env to build binary (alpine) as will be used to run in. Should not reintroduce #40 Tested locally, all fine running in archlinux. --- Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3afb9dea..ef2f4296 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,19 @@ -FROM debian:9.9-slim +FROM golang:alpine as builder +RUN \ + cd / && \ + apk add --no-cache git ca-certificates make && \ + git clone https://github.com/nshttpd/mikrotik-exporter.git && \ + cd /mikrotik-exporter && \ + go get -d -v && \ + make build -EXPOSE 9436 +FROM alpine COPY scripts/start.sh /app/ -COPY dist/mikrotik-exporter_linux_amd64 /app/mikrotik-exporter - +COPY --from=builder /mikrotik-exporter/mikrotik-exporter /app/mikrotik-exporter RUN chmod 755 /app/* -ENTRYPOINT ["/app/start.sh"] \ No newline at end of file +USER nobody +EXPOSE 9436 + +ENTRYPOINT ["/app/start.sh"]