mirror of
https://github.com/yeasy/docker_practice.git
synced 2024-11-24 15:28:54 +00:00
Add multistage builds #226
This commit is contained in:
parent
e65cf12625
commit
f2386afe6c
@ -1,12 +1,21 @@
|
|||||||
FROM golang:1.9-alpine
|
FROM golang:1.9-alpine
|
||||||
|
|
||||||
RUN apk --no-cache add git
|
RUN apk --no-cache add git
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/go/helloworld/
|
WORKDIR /go/src/github.com/go/helloworld/
|
||||||
|
|
||||||
RUN go get -d -v github.com/go-sql-driver/mysql
|
RUN go get -d -v github.com/go-sql-driver/mysql
|
||||||
|
|
||||||
COPY app.go .
|
COPY app.go .
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates
|
||||||
|
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
COPY --from=0 /go/src/github.com/go/helloworld/app .
|
COPY --from=0 /go/src/github.com/go/helloworld/app .
|
||||||
|
|
||||||
CMD ["./app"]
|
CMD ["./app"]
|
||||||
|
Loading…
Reference in New Issue
Block a user