Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +8 -9
Dockerfile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
# --- 第一阶段:编译阶段 ---
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
# 安装必要工具
|
| 5 |
RUN apk add --no-cache git
|
|
@@ -10,28 +11,26 @@ WORKDIR /app
|
|
| 10 |
RUN git clone https://github.com/router-for-me/CLIProxyAPI.git .
|
| 11 |
|
| 12 |
# 下载依赖并编译
|
|
|
|
|
|
|
| 13 |
RUN go mod download
|
| 14 |
RUN CGO_ENABLED=0 GOOS=linux go build -o server .
|
| 15 |
|
| 16 |
# --- 第二阶段:运行阶段 ---
|
| 17 |
FROM alpine:latest
|
| 18 |
|
| 19 |
-
# 安装基础运行环境
|
| 20 |
RUN apk --no-cache add ca-certificates tzdata
|
| 21 |
|
| 22 |
WORKDIR /app
|
| 23 |
|
| 24 |
-
#
|
| 25 |
COPY --from=builder /app/server .
|
| 26 |
-
|
| 27 |
-
# 2. 复制管理后台所需的静态资源(重要:否则访问 /management 会 404)
|
| 28 |
COPY --from=builder /app/static ./static
|
| 29 |
|
| 30 |
-
#
|
| 31 |
ENV PORT=7860
|
| 32 |
EXPOSE 7860
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
# -port 7860: 强制监听 HF 唯一开放的端口
|
| 36 |
-
# -config config.yaml: 显式读取你在 Files 页面创建的配置文件
|
| 37 |
CMD ["./server", "-port", "7860", "-config", "config.yaml"]
|
|
|
|
| 1 |
# --- 第一阶段:编译阶段 ---
|
| 2 |
+
# 修改这里:使用最新的 Go 镜像来支持项目要求的 1.26.0+
|
| 3 |
+
FROM golang:alpine AS builder
|
| 4 |
|
| 5 |
# 安装必要工具
|
| 6 |
RUN apk add --no-cache git
|
|
|
|
| 11 |
RUN git clone https://github.com/router-for-me/CLIProxyAPI.git .
|
| 12 |
|
| 13 |
# 下载依赖并编译
|
| 14 |
+
# 增加 GOTOOLCHAIN 设置,防止版本检查报错
|
| 15 |
+
ENV GOTOOLCHAIN=auto
|
| 16 |
RUN go mod download
|
| 17 |
RUN CGO_ENABLED=0 GOOS=linux go build -o server .
|
| 18 |
|
| 19 |
# --- 第二阶段:运行阶段 ---
|
| 20 |
FROM alpine:latest
|
| 21 |
|
| 22 |
+
# 安装基础运行环境
|
| 23 |
RUN apk --no-cache add ca-certificates tzdata
|
| 24 |
|
| 25 |
WORKDIR /app
|
| 26 |
|
| 27 |
+
# 复制产物
|
| 28 |
COPY --from=builder /app/server .
|
|
|
|
|
|
|
| 29 |
COPY --from=builder /app/static ./static
|
| 30 |
|
| 31 |
+
# 适配 HF 端口
|
| 32 |
ENV PORT=7860
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
+
# 启动
|
|
|
|
|
|
|
| 36 |
CMD ["./server", "-port", "7860", "-config", "config.yaml"]
|