From c0f9892fe340e1a00e2386072a5e718df53eb94a Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 19 Mar 2022 23:07:17 +0800 Subject: [PATCH] feat: add Dockerfile for goctl (#1666) --- tools/goctl/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/goctl/Dockerfile diff --git a/tools/goctl/Dockerfile b/tools/goctl/Dockerfile new file mode 100644 index 00000000..fe1f3e4c --- /dev/null +++ b/tools/goctl/Dockerfile @@ -0,0 +1,34 @@ +FROM golang:alpine AS builder + +LABEL stage=gobuilder + +ENV CGO_ENABLED 0 +ENV GOPROXY https://goproxy.cn,direct + +RUN apk update --no-cache && apk add --no-cache tzdata +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest +RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest + +WORKDIR /build + +ADD go.mod . +ADD go.sum . +RUN go mod download +COPY . . +RUN go build -ldflags="-s -w" -o /app/goctl ./goctl.go + + +FROM alpine + +RUN apk update --no-cache && apk add --no-cache protoc + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai +COPY --from=builder /go/bin/protoc-gen-go /usr/bin/protoc-gen-go +COPY --from=builder /go/bin/protoc-gen-go-grpc /usr/bin/protoc-gen-go-grpc +ENV TZ Asia/Shanghai + +WORKDIR /app +COPY --from=builder /app/goctl /app/goctl + +CMD ["./goctl"]