forked from the-cc-dev/inlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (25 loc) · 1.1 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
FROM golang:1.11-alpine as build
WORKDIR /go/src/github.com/inlets/inlets
COPY .git .git
COPY vendor vendor
COPY pkg pkg
COPY cmd cmd
COPY main.go .
ARG GIT_COMMIT
ARG VERSION
ARG OPTS
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./function/vendor/*"))" || { echo "Run \"gofmt -s -w\" on your Golang code"; exit 1; } \
&& CGO_ENABLED=0 go test $(go list ./... | grep -v /vendor/) -cover
# add user in this stage because it cannot be done in next stage which is built from scratch
# in next stage we'll copy user and group information from this stage
RUN env ${OPTS} CGO_ENABLED=0 go build -ldflags "-s -w -X main.GitCommit=${GIT_COMMIT} -X main.Version=${VERSION}" -a -installsuffix cgo -o /usr/bin/inlets \
&& addgroup -S app \
&& adduser -S -g app app
FROM scratch
COPY --from=build /etc/passwd /etc/group /etc/
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /usr/bin/inlets /usr/bin/
USER app
EXPOSE 80
ENTRYPOINT ["/usr/bin/inlets"]
CMD ["--help"]