File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 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
2
5
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
4
13
5
14
WORKDIR /go/src/github.com/openfaas/nats-queue-worker
6
15
@@ -17,27 +26,20 @@ COPY .git .
17
26
18
27
ARG go_opts
19
28
20
- RUN apk add --no-cache git
21
-
22
29
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\/ //' ) \
23
30
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
24
31
&& env $go_opts CGO_ENABLED=0 go build \
25
32
--ldflags "-s -w \
26
33
-X github.com/openfaas/nats-queue-worker/version.GitCommit=${GIT_COMMIT}\
27
34
-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 .
32
36
33
37
# we can't add user in next stage because it's from scratch
34
38
# ca-certificates and tmp folder are also missing in scratch
35
39
# so we add all of it here and copy files in next stage
36
40
FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot
37
41
38
42
WORKDIR /
39
- COPY --from=build /usr/bin/controller .
40
43
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 .
43
45
CMD ["./app" ]
You can’t perform that action at this time.
0 commit comments