From f2386afe6c99d3752310d3c4669d94e5badc4cea Mon Sep 17 00:00:00 2001 From: khs1994 Date: Fri, 24 Nov 2017 18:37:38 +0800 Subject: [PATCH] Add multistage builds #226 --- image/demo/multistage-builds/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/image/demo/multistage-builds/Dockerfile b/image/demo/multistage-builds/Dockerfile index 5516262..c54c11d 100644 --- a/image/demo/multistage-builds/Dockerfile +++ b/image/demo/multistage-builds/Dockerfile @@ -1,12 +1,21 @@ FROM golang:1.9-alpine + RUN apk --no-cache add git + WORKDIR /go/src/github.com/go/helloworld/ + RUN go get -d -v github.com/go-sql-driver/mysql + COPY app.go . + RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . FROM alpine:latest + RUN apk --no-cache add ca-certificates + WORKDIR /root/ + COPY --from=0 /go/src/github.com/go/helloworld/app . + CMD ["./app"]