Skip to content

Instantly share code, notes, and snippets.

@NiklasMerz
Last active January 5, 2019 14:35
Show Gist options
  • Save NiklasMerz/d8c50ed27f3b0393b3d688234e4f77fd to your computer and use it in GitHub Desktop.
Save NiklasMerz/d8c50ed27f3b0393b3d688234e4f77fd to your computer and use it in GitHub Desktop.
Sample Dockerfile for building and running Go applications
FROM golang:alpine as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY . /go/src/github.com/niklasmerz/myproject
RUN set -x \
&& cd /go/src/github.com/niklasmerz/myproject \
&& go build \
&& mv myproject /usr/bin/myproject \
&& rm -rf /go \
&& echo "Build complete."
FROM alpine:latest
RUN apk add --no-cache \
ca-certificates
COPY --from=builder /usr/bin/myproject /usr/bin/myproject
ENTRYPOINT [ "myproject" ]
CMD [ "" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment