-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
30 lines (25 loc) · 938 Bytes
/
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
# syntax = docker.io/docker/dockerfile:1.1.3-experimental
# target: gopls-builder
ARG GOLANG_VERSION
ARG ALPINE_VERSION
FROM docker.io/golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS gopls-builder
ENV OUTDIR=/out \
GO111MODULE='on'
RUN set -eux && \
apk add --no-cache \
ca-certificates \
git
RUN set -eux && \
mkdir -p "${OUTDIR}/usr/bin" && \
CGO_ENABLED=0 GOBIN=${OUTDIR}/usr/bin/ go get -a -v -tags='osusergo,netgo,static,static_build' -installsuffix='netgo' -ldflags='-d -s -w "-extldflags=-fno-PIC -static"' \
golang.org/x/tools/gopls@master
# target: nonroot
FROM gcr.io/distroless/static:nonroot AS nonroot
# target: gopls
FROM scratch AS gopls
COPY --from=nonroot /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=nonroot /etc/passwd /etc/passwd
COPY --from=nonroot /etc/group /etc/group
COPY --from=gopls-builder --chown=nonroot:nonroot /out/ /
USER nonroot:nonroot
ENTRYPOINT ["/usr/bin/gopls"]