dongsiqie commited on
Commit
13deb19
1 Parent(s): 87a0c20

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -0
Dockerfile ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build Stage
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/renqabs/gopb.git /workspace/app
10
+
11
+ # 设置工作目录为之前克隆的项目目录
12
+ WORKDIR /workspace/app
13
+
14
+ # 编译 go 项目。-ldflags="-s -w" 是为了减少编译后的二进制大小
15
+ RUN go build -ldflags="-s -w" -tags netgo -trimpath -o go-proxy-bingai main.go
16
+
17
+ # Runtime Stage
18
+ # 使用轻量级的 alpine 镜像作为运行时的基础镜像
19
+ FROM alpine
20
+
21
+ # 设置工作目录
22
+ WORKDIR /workspace/app
23
+
24
+ # 从构建阶段复制编译后的二进制文件到运行时镜像中
25
+ COPY --from=builder /workspace/app/go-proxy-bingai .
26
+
27
+ # 设置环境变量
28
+ ENV BYPASS_SERVER="https://v2ymzk-8080.csb.app"
29
+ ENV APIKEY="sk-bing"
30
+
31
+ # 暴露8080端口
32
+ EXPOSE 8080
33
+
34
+ # 容器启动时运行的命令
35
+ CMD ["/workspace/app/go-proxy-bingai"]