-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (21 loc) · 776 Bytes
/
Dockerfile
File metadata and controls
34 lines (21 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM golang:1.11 as builder
ENV CGO_ENABLED=0
RUN mkdir -p /go/src/github.com/openfaas-incubator/vcenter-connector
WORKDIR /go/src/github.com/openfaas-incubator/vcenter-connector
COPY vendor vendor
COPY pkg pkg
COPY main.go .
# Run a gofmt and exclude all vendored code.
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN go test -v ./...
# Stripping via -ldflags "-s -w"
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o ./connector
FROM alpine:3.10 as ship
RUN addgroup -S app \
&& adduser -S -g app app
WORKDIR /home/app
EXPOSE 8989
COPY --from=builder /go/src/github.com/openfaas-incubator/vcenter-connector/connector .
RUN chown -R app:app ./
USER app
CMD ["./connector"]