Skip to content

Commit

Permalink
add dockerfile (#27)
Browse files Browse the repository at this point in the history
* add dockerfile

* Modify GOPROXY,GOSUMDB to be optional

* fix: update zh contributing doc index
  • Loading branch information
coder2z authored Nov 14, 2023
1 parent a6f2b57 commit b468acf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM golang:alpine AS builder
RUN mkdir /app
ADD . /app/
WORKDIR /app

ARG GOPROXY
ARG GOSUMDB

RUN go env -w GOPROXY=${GOPROXY}
RUN go env -w GOSUMDB=${GOSUMDB}
RUN go mod download
RUN go build -o bin/ trpc/trpc.go
RUN chmod +x bin/trpc

# protoc-gen-go
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
# mockgen
RUN go install go.uber.org/mock/mockgen@latest
# goimports
RUN go install golang.org/x/tools/cmd/goimports@latest
# protoc-gen-validate
RUN go install github.com/envoyproxy/protoc-gen-validate@latest
RUN go install github.com/envoyproxy/protoc-gen-validate/cmd/protoc-gen-validate-go@latest

FROM golang:alpine
RUN apk update --no-cache && apk add --no-cache protoc flatc

ARG GOPROXY
ARG GOSUMDB

RUN go env -w GOPROXY=${GOPROXY}
RUN go env -w GOSUMDB=${GOSUMDB}

COPY --from=builder /app/bin/trpc /usr/local/bin/
COPY --from=builder /go/bin /go/bin
WORKDIR /workspace
RUN trpc setup

ENTRYPOINT ["trpc"]

11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
VERSION := $(shell cat install/VERSION)
DOCKER_IMAGE := trpc-group/trpc-cmdline
GOPROXY := https://goproxy.cn
GOSUMDB := sum.golang.org

PHONY: fmt bindata_release release submodules image


Expand Down Expand Up @@ -32,6 +36,7 @@ submodules:
# -rm -rf install/submodules/* && git submodule update --remote

image:
@mkdir -p bin
@GOOS=linux go build -o bin/ trpc/trpc.go
@docker build -t trpc-cmdline:${VERSION} .
@docker build \
--build-arg GOPROXY=${GOPROXY} \
--build-arg GOSUMDB=${GOSUMDB} \
-t ${DOCKER_IMAGE}:${VERSION} .
2 changes: 1 addition & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ out

## 贡献

本开源项目欢迎任何贡献,请阅读 [贡献指南](CONTRIBUTING.md) 以获取更多信息。
本开源项目欢迎任何贡献,请阅读 [贡献指南](CONTRIBUTING.zh_CN.md) 以获取更多信息。

0 comments on commit b468acf

Please sign in to comment.