Created
August 9, 2017 21:24
-
-
Save PaluMacil/8f5d0ef6f45a9ba7a5288b8c63583cab to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile for building a ~10 MB Go container
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:1.8.3 as goget | |
LABEL maintainer="dcwolf@gmail.com" | |
ADD ./main.go /go/src/github.com/palumacil/example/main.go | |
ADD ./handler.go /go/src/github.com/palumacil/example/handler.go | |
ADD ./config.go /go/src/github.com/palumacil/example/config.go | |
RUN go get .\.. | |
FROM golang:1.8.3-alpine as gobuild | |
LABEL maintainer="dcwolf@gmail.com" | |
COPY --from=goget /go/src /go/src | |
RUN go install github.com/palumacil/example | |
FROM alpine | |
LABEL maintainer="dcwolf@gmail.com" | |
COPY --from=gobuild /go/bin /go/bin | |
EXPOSE 80 | |
CMD /go/bin/example -port=80 -secrets=/run/secrets/example.json -log=/logs/example.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$projectPath = (Get-Item -Path "." -Verbose).FullName
$secrets = "$env:USERPROFILE\secrets:/run/secrets"
docker rm -f example
docker rmi -f example:test
docker build -t example:test .
docker run -d -v "$projectPath/logs:/logs" -v "$secrets" -p 8119:80 --name example example:test