From 88b072f48ea4d70cf554cebeffbd27b34504f5c4 Mon Sep 17 00:00:00 2001 From: Andy Cobaugh Date: Fri, 19 Jul 2019 12:24:31 -0400 Subject: [PATCH] Add Dockerfile to project (#98) * add Dockerfile * dockerfile: switch to multi-stage build to lighten up the final image * dockerfile: update to latest images, and update the 2nd stage image on build --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..369d15c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.12-alpine3.10 as builder + +WORKDIR /go/src/vsphere-influxdb-go +COPY . . +RUN apk --update add --virtual build-deps git +RUN go get -d -v ./... +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo + +FROM alpine:3.10 +RUN apk update \ + && apk upgrade \ + && apk 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 + +CMD ["/vsphere-influxdb-go"]