jjf1999 commited on
Commit
c3bf2fa
·
verified ·
1 Parent(s): 0752d51

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -27
Dockerfile CHANGED
@@ -1,34 +1,48 @@
1
- # Multi-stage build for gcli2api
2
- FROM python:3.13-slim as base
3
-
4
- # Set environment variables
5
- ENV PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1 \
7
- PIP_NO_CACHE_DIR=1 \
8
- PIP_DISABLE_PIP_VERSION_CHECK=1 \
9
- TZ=Asia/Shanghai
10
-
11
- # Install tzdata and set timezone
12
- RUN apt-get update && \
13
- apt-get install -y --no-install-recommends tzdata && \
14
- ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
15
- echo "Asia/Shanghai" > /etc/timezone && \
16
- apt-get clean && \
17
- rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  WORKDIR /app
20
 
21
- # Copy only requirements first for better caching
22
- COPY requirements.txt .
23
 
24
- # Install Python dependencies
25
- RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Copy application code
28
- COPY . .
 
 
29
 
30
- # Expose port
31
- EXPOSE 7861
 
32
 
33
- # Default command
34
- CMD ["python", "web.py"]
 
1
+ # ==========================================
2
+ # 第一阶段:利用云原生挂载拉取私有源码并编译
3
+ # ==========================================
4
+ FROM golang:1.26-alpine AS builder
5
+
6
+ # 安装 git 和 openssh 以便拉取私有仓库
7
+ RUN apk add --no-cache git openssh-client
8
+
9
+ WORKDIR /build
10
+
11
+ # 🎯【核心破局】:使用 Hugging Face 官方标准的 Secret 挂载读取机制
12
+ # 这行命令会临时把你在 HF 后台填写的 Secret 安全地挂载到容器内的 /run/secrets/GH_TOKEN 文件中
13
+ RUN --mount=type=secret,id=GH_TOKEN \
14
+ GH_TOKEN_VAL=$(cat /run/secrets/GH_TOKEN) && \
15
+ if [ -z "$GH_TOKEN_VAL" ]; then echo "❌ 错误:Hugging Face 的 GH_TOKEN 读取失败,请检查 Settings 里的 Secret 命名是否完全一致!" && exit 1; fi && \
16
+ git clone https://${GH_TOKEN_VAL}@github.com/jjf1126/Agent-Platform-Studio.git .
17
+
18
+ # 现场执行依赖拉取与物理编译
19
+ RUN go mod download && \
20
+ CGO_ENABLED=0 go build -buildvcs=false -trimpath -ldflags="-s -w" -o vproxy ./cmd/vproxy \
21
+ && go clean -cache -modcache -testcache
22
+
23
+ # ==========================================
24
+ # 第二阶段:构建最终常驻运行的纯净镜像
25
+ # ==========================================
26
+ FROM alpine:3.20
27
+
28
+ RUN apk add --no-cache ca-certificates tzdata bash
29
 
30
  WORKDIR /app
31
 
32
+ # 1. 复制编译好的主程序
33
+ COPY --from=builder /build/vproxy /app/vproxy
34
 
35
+ # 2. 将拉取下来的私有配置文件夹物理复制到运行目录
36
+ COPY --from=builder /build/config/ /app/config/
37
 
38
+ # 3. 锁定环境变量路径
39
+ ENV VPROXY_CONFIG=/app/config/config.json
40
+ ENV VPROXY_API_KEYS=/app/config/api_keys.txt
41
+ ENV VPROXY_MODELS=/app/config/models.json
42
 
43
+ # 4. 强制注入端口适配 Hugging Face 7860 核心网关限制
44
+ ENV PORT=7860
45
+ EXPOSE 7860
46
 
47
+ # 5. 彻底废除 entrypoint 脚本,直接以本地文件运行模式启动二进制
48
+ CMD ["./vproxy"]