Skip to content

Instantly share code, notes, and snippets.

@narqo
Created April 22, 2017 19:39
Show Gist options
  • Save narqo/cadc3a676785647145fb7cf99f4ead7e to your computer and use it in GitHub Desktop.
Save narqo/cadc3a676785647145fb7cf99f4ead7e to your computer and use it in GitHub Desktop.
Example of multi-stage build Dockerfile, introduced in docker v17.05.0
# Requires docker >= v17.05.0-ce-rc1
# See http://blog.alexellis.io/mutli-stage-docker-builds/
# Usage:
# > docker build -t syseng-exporter .
FROM golang:1.8 AS go-builder
WORKDIR /go/src/syseng_exporter
COPY *.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o syseng_exporter .
FROM alpine:3.3
RUN apk --no-cache add ca-certificates
COPY --from=go-builder /go/src/syseng_exporter/syseng_exporter /
CMD ["/syseng_exporter"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment