Skip to content

Instantly share code, notes, and snippets.

@sachk
Created August 17, 2018 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachk/ec1a5ced746003c34f158d259985baaa to your computer and use it in GitHub Desktop.
Save sachk/ec1a5ced746003c34f158d259985baaa to your computer and use it in GitHub Desktop.
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