Created
February 18, 2019 23:49
-
-
Save timjonesdev/69d888f180e8ca5e13f6cb548ad96c9e to your computer and use it in GitHub Desktop.
A Composite Dockerfile
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
# ------------------------------------------------------- | |
# Build the go source | |
# ------------------------------------------------------- | |
FROM docker.io/golang:1.11 as go-builder | |
# copy simple go application into the container | |
COPY app/api/main.go $GOPATH/src/app/main.go | |
# change the working directory, for convenience | |
WORKDIR $GOPATH/src/app | |
# build the Go binary and create some directories to copy in later stages | |
RUN CGO_ENABLED=0 go build -o /go/bin/app ./main.go && \ | |
echo "App built" | |
# ------------------------------------------------------- | |
# Put the go source into the scratch_and_sniff base image | |
# ------------------------------------------------------- | |
FROM scratch_and_sniff | |
# copy source files from go-builder stage into the scratch container | |
COPY --from=go-builder /go/bin/app /usr/bin/app | |
# change working directory, so CMD is brief | |
WORKDIR /usr/bin/ | |
# run the Go application | |
CMD ["app"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment