add official Dockerfile

This commit is contained in:
Josh Humphries 2019-05-28 15:07:50 -04:00
parent 7e4045565f
commit 80b118ff63
4 changed files with 32 additions and 1 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
dist/
VERSION

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM golang:1.11.10-alpine as builder
MAINTAINER FullStory Engineering
RUN apk update && apk add --no-cache ca-certificates git gcc g++ libc-dev
# create non-privileged group and user
RUN addgroup -S grpcurl && adduser -S grpcurl -G grpcurl
# build grpcurl
WORKDIR /tmp/fullstorydev/grpcurl
# copy just the files/sources we need to build grpcurl
COPY VERSION *.go go.* /tmp/fullstorydev/grpcurl/
COPY cmd /tmp/fullstorydev/grpcurl/cmd
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o /grpcurl -ldflags "-w -extldflags \"-static\" -X \"main.version=$(cat VERSION)\"" ./cmd/grpcurl
# New FROM so we have a nice'n'tiny image
FROM scratch
WORKDIR /
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /grpcurl /bin/grpcurl
USER grpcurl
ENTRYPOINT ["/bin/grpcurl"]

View File

@ -25,6 +25,12 @@ release:
@GO111MODULE=off go get github.com/goreleaser/goreleaser
goreleaser --rm-dist
.PHONY: docker
docker:
@echo $(dev_build_version) > VERSION
docker build -t fullstorydev/grpcurl:$(dev_build_version) .
@rm VERSION
.PHONY: checkgofmt
checkgofmt:
gofmt -s -l .

View File

@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"time"
@ -161,7 +162,7 @@ func main() {
os.Exit(0)
}
if *printVersion {
fmt.Fprintf(os.Stderr, "%s %s\n", os.Args[0], version)
fmt.Fprintf(os.Stderr, "%s %s\n", filepath.Base(os.Args[0]), version)
os.Exit(0)
}