搭建micro服务2

使用ubuntu镜像

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM ubuntu

WORKDIR /home

ENV GOPATH /go
ENV PATH /usr/local/go/bin:$GOPATH/bin:$PATH

# 换源
RUN echo "deb http://repo.huaweicloud.com/ubuntu focal main restricted\n\
deb http://repo.huaweicloud.com/ubuntu focal-updates main restricted\n\
deb http://repo.huaweicloud.com/ubuntu focal universe\n\
deb http://repo.huaweicloud.com/ubuntu focal-updates universe\n\
deb http://repo.huaweicloud.com/ubuntu focal multiverse\n\
deb http://repo.huaweicloud.com/ubuntu focal-updates multiverse\n\
deb http://repo.huaweicloud.com/ubuntu focal-backports main restricted universe multiverse\n\
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted\n\
deb http://security.ubuntu.com/ubuntu/ focal-security universe\n\
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse" > /etc/apt/sources.list

# 安装系统软件
RUN apt update && \
apt install -y curl unzip

# 安装 protoc
RUN curl -OL https://ghproxy.com/https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/protoc-3.19.1-linux-x86_64.zip && \
unzip -o protoc-3.19.1-linux-x86_64.zip -d /usr/local bin/protoc && \
unzip -o protoc-3.19.1-linux-x86_64.zip -d /usr/local 'include/*' && \
rm -f protoc-3.19.1-linux-x86_64.zip

# 安装 go
RUN curl -OL https://studygolang.com/dl/golang/go1.15.15.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.15.15.linux-amd64.tar.gz && \
rm -f go1.15.15.linux-amd64.tar.gz

# go 代理 库
RUN go env -w GO111MODULE=on && \
go env -w GOPROXY=https://goproxy.cn,direct && \
go get github.com/golang/protobuf/proto && \
go get github.com/golang/protobuf/protoc-gen-go && \
go get github.com/micro/micro/v3/cmd/protoc-gen-micro && \
go get github.com/micro/micro/v3

CMD ["/bin/bash"]