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
| FROM golang:latest
RUN sed -i "s/deb.debian.org/repo.huaweicloud.com/" /etc/apt/sources.list && \ apt-get update && \ apt-get install -y jq unzip && \ rm -rf /var/lib/apt/lists/*
RUN protoc_version=$(wget -qO- -t1 -T2 "https://api.github.com/repos/protocolbuffers/protobuf/releases/latest" | jq -r '.tag_name') && \ wget https://ghproxy.com/https://github.com/protocolbuffers/protobuf/releases/download/${protoc_version}/protoc-${protoc_version:1}-linux-x86_64.zip && \ unzip protoc-${protoc_version:1}-linux-x86_64.zip bin/protoc -d $(go env GOPATH) && \ rm -f protoc-${protoc_version:1}-linux-x86_64.zip
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct
RUN go install github.com/go-micro/cli/cmd/go-micro@latest
RUN go-micro new service helloworld && \ cd helloworld && \ sed -i '/micro.Version(version),/a\\t\tmicro.Address(":8080"),' main.go && \ make init proto tidy
CMD cd helloworld && go run main.go
|