Create Dockerfile
Browse files- Dockerfile +33 -0
Dockerfile
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Build Stage
|
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"]
|