Last active
August 24, 2018 05:22
-
-
Save casualjim/dfeb922a5cd93a0b0cd69c908b4c2c30 to your computer and use it in GitHub Desktop.
Dockerfile for a static binary scratch image with all the necessary data
This file contains 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 golang:alpine as base | |
RUN mkdir -p /stage/data /stage/etc/ssl/certs &&\ | |
apk add --no-cache musl-dev gcc ca-certificates mailcap upx tzdata zip &&\ | |
update-ca-certificates &&\ | |
cp /etc/ssl/certs/ca-certificates.crt /stage/etc/ssl/certs/ca-certificates.crt &&\ | |
cp /etc/mime.types /stage/etc/mime.types | |
WORKDIR /usr/share/zoneinfo | |
RUN zip -r -0 /stage/zoneinfo.zip . | |
ADD . /go/src/github.com/casualjim/thething | |
WORKDIR /go/src/github.com/casualjim/thething | |
RUN go build -o /stage/thething --ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/thething | |
RUN upx /stage/thething | |
# Build the dist image | |
FROM scratch | |
COPY --from=base /stage / | |
ENV ZONEINFO /zoneinfo.zip | |
ENTRYPOINT [ "/thething" ] | |
CMD ["--help"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment