Update Dockerfile
Browse files- Dockerfile +2 -36
Dockerfile
CHANGED
@@ -1,37 +1,3 @@
|
|
1 |
-
|
2 |
-
# 使用 golang:alpine 作为构建阶段的基础镜像
|
3 |
-
FROM golang:alpine AS builder
|
4 |
-
|
5 |
-
# 添加 git,以便之后能从GitHub克隆项目
|
6 |
-
RUN apk --no-cache add git
|
7 |
-
|
8 |
-
# 从 GitHub 克隆 go-proxy-bingai 项目到 /workspace/app 目录下
|
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 项目。-ldflags="-s -w" 是为了减少编译后的二进制大小
|
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="kJs8hD92ncMzLaoQWYtX5rG6bE3fZ4iO"
|
31 |
-
|
32 |
-
|
33 |
-
# 暴露8080端口
|
34 |
EXPOSE 8080
|
35 |
-
|
36 |
-
# 容器启动时运行的命令
|
37 |
-
CMD ["/workspace/app/go-proxy-bingai"]
|
|
|
1 |
+
FROM zklcdc/go-proxy-bingai:v1.12.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
EXPOSE 8080
|
3 |
+
CMD ["/app/go-proxy-bingai"]
|
|
|
|