forked from inlets/inlets-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (31 loc) · 1.37 KB
/
Dockerfile
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
35
36
37
38
39
40
41
42
FROM teamserverless/license-check:0.3.6 as license-check
FROM golang:1.13 as builder
ENV CGO_ENABLED=0
ENV GO111MODULE=on
COPY --from=license-check /license-check /usr/bin/
RUN mkdir -p /go/src/github.com/inlets/inlets-operator
WORKDIR /go/src/github.com/inlets/inlets-operator
COPY . .
ARG OPTS
RUN go mod download
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*")
RUN go test -v ./...
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') && \
GIT_COMMIT=$(git rev-list -1 HEAD) && \
env ${OPTS} CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
-X github.com/inlets/inlets-operator/pkg/version.Release=${VERSION} \
-X github.com/inlets/inlets-operator/pkg/version.SHA=${GIT_COMMIT}" \
-a -installsuffix cgo -o inlets-operator . && \
addgroup --system app && \
adduser --system --ingroup app app && \
mkdir /scratch-tmp
# we can't add user in next stage because it's from scratch
# ca-certificates and tmp folder are also missing in scratch
# so we add all of it here and copy files in next stage
FROM scratch
COPY --from=builder /etc/passwd /etc/group /etc/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder --chown=app:app /scratch-tmp /tmp/
COPY --from=builder /go/src/github.com/inlets/inlets-operator/inlets-operator .
USER app
CMD ["./inlets-operator"]