dockerfile: switch to multi-stage build to lighten up the final image

This commit is contained in:
Andy Cobaugh 2018-11-13 22:58:19 -05:00
parent 853e072a05
commit a18c850946
1 changed files with 9 additions and 7 deletions

View File

@ -1,14 +1,16 @@
FROM golang:1.10-alpine3.7
FROM golang:1.10-alpine3.7 as builder
WORKDIR /go/src/vsphere-influxdb-go
COPY . .
RUN apk --update add --virtual build-deps git \
&& go get -d -v ./... \
&& go install -v ./... \
&& rm -rf /go/src \
&& apk del build-deps
RUN apk --update add --virtual build-deps git
RUN go get -d -v ./...
#RUN go install -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo
RUN addgroup -S spock && adduser -S spock -G spock
FROM alpine:latest
RUN apk --update add ca-certificates \
&& addgroup -S spock && adduser -S spock -G spock
COPY --from=0 /go/src/vsphere-influxdb-go/vsphere-influxdb-go /vsphere-influxdb-go
USER spock