Skip to content

Commit a722f52

Browse files
committed
Remove user statement
This is not required for the distroless image Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 57b99c1 commit a722f52

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
FROM golang:1.16-alpine as build
1+
2+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.16-alpine as build
3+
4+
ENV GO111MODULE=on
25
ENV CGO_ENABLED=0
3-
ENV GO111MODULE=off
6+
7+
ARG TARGETPLATFORM
8+
ARG BUILDPLATFORM
9+
ARG TARGETOS
10+
ARG TARGETARCH
11+
12+
RUN apk add --no-cache git
413

514
WORKDIR /go/src/github.com/openfaas/nats-queue-worker
615

@@ -17,27 +26,20 @@ COPY .git .
1726

1827
ARG go_opts
1928

20-
RUN apk add --no-cache git
21-
2229
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
2330
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
2431
&& env $go_opts CGO_ENABLED=0 go build \
2532
--ldflags "-s -w \
2633
-X github.com/openfaas/nats-queue-worker/version.GitCommit=${GIT_COMMIT}\
2734
-X github.com/openfaas/nats-queue-worker/version.Version=${VERSION}" \
28-
-a -installsuffix cgo -o app . \
29-
&& addgroup -S app \
30-
&& adduser -S -g app app \
31-
&& mkdir /scratch-tmp
35+
-a -installsuffix cgo -o app .
3236

3337
# we can't add user in next stage because it's from scratch
3438
# ca-certificates and tmp folder are also missing in scratch
3539
# so we add all of it here and copy files in next stage
3640
FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot
3741

3842
WORKDIR /
39-
COPY --from=build /usr/bin/controller .
4043
USER nonroot:nonroot
41-
42-
COPY --from=golang /go/src/github.com/openfaas/nats-queue-worker/app .
44+
COPY --from=build /go/src/github.com/openfaas/nats-queue-worker/app .
4345
CMD ["./app"]

0 commit comments

Comments
 (0)