blob: 0f71406949412955aad09900ae4fa4e4d3b95538 [file] [log] [blame]
Scott Baker4a35a702019-11-26 08:17:33 -08001FROM golang:1.11.10-alpine as builder
2MAINTAINER FullStory Engineering
3
4# currently, a module build requires gcc (so Go tool can build
5# module-aware versions of std library; it ships only w/ the
6# non-module versions)
7RUN apk update && apk add --no-cache ca-certificates git gcc g++ libc-dev
8# create non-privileged group and user
9RUN addgroup -S grpcurl && adduser -S grpcurl -G grpcurl
10
11WORKDIR /tmp/fullstorydev/grpcurl
12# copy just the files/sources we need to build grpcurl
13COPY VERSION *.go go.* /tmp/fullstorydev/grpcurl/
14COPY cmd /tmp/fullstorydev/grpcurl/cmd
15# and build a completely static binary (so we can use
16# scratch as basis for the final image)
17ENV CGO_ENABLED=0
18ENV GOOS=linux
19ENV GOARCH=amd64
20ENV GO111MODULE=on
21RUN go build -o /grpcurl \
22 -ldflags "-w -extldflags \"-static\" -X \"main.version=$(cat VERSION)\"" \
23 ./cmd/grpcurl
24
25# New FROM so we have a nice'n'tiny image
26FROM scratch
27WORKDIR /
28COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
29COPY --from=builder /etc/passwd /etc/passwd
30COPY --from=builder /grpcurl /bin/grpcurl
31USER grpcurl
32
33ENTRYPOINT ["/bin/grpcurl"]