Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +37 -0
Dockerfile
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 构建阶段
|
2 |
+
FROM golang:1.21-alpine AS builder
|
3 |
+
|
4 |
+
# 安装必要的构建工具
|
5 |
+
RUN apk add --no-cache git
|
6 |
+
|
7 |
+
# 设置工作目录
|
8 |
+
WORKDIR /build
|
9 |
+
|
10 |
+
# 复制go mod文件(如果有的话)
|
11 |
+
COPY go.mod go.sum* ./
|
12 |
+
|
13 |
+
# 下载依赖(如果有go.mod的话)
|
14 |
+
RUN if [ -f go.mod ]; then go mod download; fi
|
15 |
+
|
16 |
+
# 复制源代码
|
17 |
+
COPY . .
|
18 |
+
|
19 |
+
# 构建应用
|
20 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gemini-relay .
|
21 |
+
|
22 |
+
# 运行阶段
|
23 |
+
FROM alpine:latest
|
24 |
+
|
25 |
+
# 安装ca证书,用于HTTPS请求
|
26 |
+
RUN apk --no-cache add ca-certificates
|
27 |
+
|
28 |
+
WORKDIR /root/
|
29 |
+
|
30 |
+
# 从构建阶段复制二进制文件
|
31 |
+
COPY --from=builder /build/gemini-relay .
|
32 |
+
|
33 |
+
# 暴露端口
|
34 |
+
EXPOSE 8080
|
35 |
+
|
36 |
+
# 运行应用
|
37 |
+
CMD ["./gemini-relay"]
|