Update Dockerfile
Browse files- Dockerfile +14 -18
Dockerfile
CHANGED
@@ -2,36 +2,32 @@
|
|
2 |
# 使用 golang:alpine 作为构建阶段的基础镜像
|
3 |
FROM golang:alpine AS builder
|
4 |
|
5 |
-
# 添加 git
|
6 |
-
RUN apk --no-cache add git
|
|
|
|
|
7 |
|
8 |
-
#
|
9 |
-
RUN git clone https://github.com/Harry-zklcdc/go-proxy-bingai.git /workspace/app
|
10 |
-
# 切换到特定版本
|
11 |
-
# RUN cd /workspace/app && git reset --hard 922b8c47d2d5c6e77137f29b78c8da3de95be841
|
12 |
-
|
13 |
-
# 设置工作目录为之前克隆的项目目录
|
14 |
WORKDIR /workspace/app
|
15 |
|
16 |
-
# 编译 go
|
17 |
RUN go build -ldflags="-s -w" -tags netgo -trimpath -o go-proxy-bingai main.go
|
18 |
|
19 |
# Runtime Stage
|
20 |
-
# 使用轻量级的 alpine
|
21 |
FROM alpine
|
22 |
|
23 |
-
#
|
24 |
WORKDIR /workspace/app
|
25 |
|
26 |
-
#
|
27 |
COPY --from=builder /workspace/app/go-proxy-bingai .
|
28 |
|
29 |
-
#
|
30 |
-
ENV Go_Proxy_BingAI_USER_TOKEN_1="
|
31 |
-
|
32 |
|
33 |
-
#
|
34 |
EXPOSE 8080
|
35 |
|
36 |
-
#
|
37 |
-
CMD ["/workspace/app/go-proxy-bingai"]
|
|
|
2 |
# 使用 golang:alpine 作为构建阶段的基础镜像
|
3 |
FROM golang:alpine AS builder
|
4 |
|
5 |
+
# 添加 git,并且清除缓存🧹
|
6 |
+
RUN apk --no-cache add git && \
|
7 |
+
git clone https://github.com/Harry-zklcdc/go-proxy-bingai.git /workspace/app && \
|
8 |
+
apk del git
|
9 |
|
10 |
+
# 设置工作目录
|
|
|
|
|
|
|
|
|
|
|
11 |
WORKDIR /workspace/app
|
12 |
|
13 |
+
# 编译 go 项目
|
14 |
RUN go build -ldflags="-s -w" -tags netgo -trimpath -o go-proxy-bingai main.go
|
15 |
|
16 |
# Runtime Stage
|
17 |
+
# 使用轻量级的 alpine 镜像🪞
|
18 |
FROM alpine
|
19 |
|
20 |
+
# 设置工作目录💼
|
21 |
WORKDIR /workspace/app
|
22 |
|
23 |
+
# 从构建阶段复制编译后的二进制文件👔
|
24 |
COPY --from=builder /workspace/app/go-proxy-bingai .
|
25 |
|
26 |
+
# (可选)设置环境变量✍️
|
27 |
+
# ENV Go_Proxy_BingAI_USER_TOKEN_1="kJs8hD92ncMzLaoQWYtX5rG6bE3fZ4iO"
|
|
|
28 |
|
29 |
+
# 端口
|
30 |
EXPOSE 8080
|
31 |
|
32 |
+
# 容器运行✅
|
33 |
+
CMD ["/workspace/app/go-proxy-bingai"]
|