-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile-web
43 lines (30 loc) · 1.24 KB
/
Dockerfile-web
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 athena-project-dev:v1.0 as builder
LABEL authors="heige"
# 设置环境变量
ENV CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct
WORKDIR /app
COPY . .
RUN go mod download && go mod verify
# 编译构建应用程序
RUN cd /app/cmd/web && go build -ldflags="-s -w" -o athena-web
# 将上面构建好的二进制文件复制到容器中运行
FROM debian:bullseye-slim
# 设置时区和lang
ENV TZ=Asia/Shanghai LANG="zh_CN.UTF-8"
WORKDIR /app
# 设置gRPC微服务和metrics服务运行端口
EXPOSE 1337
EXPOSE 2337
EXPOSE 3337
EXPOSE 8081
EXPOSE 8091
# 设置deb镜像源,这里我使用aliyun的镜像
RUN echo "deb http://mirrors.aliyun.com/debian bullseye main" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian-security bullseye-security main" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/debian bullseye-updates main" >> /etc/apt/sources.list && \
apt-get update && apt-get install -y ca-certificates vim bash curl net-tools wget \
apt-transport-https && update-ca-certificates && apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 将构建阶段的二进制文件复制到工作目录中
COPY --from=builder /app/cmd/web/athena-web /app/athena-web
CMD ["/app/athena-web"]