Created
August 17, 2018 23:51
-
-
Save sachk/ec1a5ced746003c34f158d259985baaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:bionic as builder | |
WORKDIR /root/go/src/github.com/boynux/squid-exporter | |
COPY . . | |
# Install build utilities | |
RUN apt update && apt upgrade && apt install -y gccgo gccgo-go upx git | |
# Compile the binary statically, so it can be run without libraries using gccgo | |
# and with extra flags to remove debug info. | |
RUN go get | |
RUN go install -compiler gccgo -a -gccgoflags "-static -s -w" . | |
# Compress the binaries with upx to make them even smaller | |
RUN upx --brute /root/go/bin/squid-exporter | |
FROM scratch | |
COPY --from=builder /root/go/bin/squid-exporter /usr/local/bin/squid-exporter | |
EXPOSE 9301 | |
ENTRYPOINT ["/usr/local/bin/squid-exporter"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment