jlshu commited on
Commit
0df4e43
·
verified ·
1 Parent(s): 6a1b727

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -0
Dockerfile ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==========================================
2
+ # 第一阶段:拉取私有源码并在线现场编译
3
+ # ==========================================
4
+ FROM golang:1.26-alpine AS builder
5
+
6
+ # 安装 git 以便拉取 GitHub 仓库
7
+ RUN apk add --no-cache git
8
+
9
+ WORKDIR /build
10
+
11
+ # 🎯【核心突破】:接收从 Hugging Face 传进来的 GitHub 私人访问令牌 (PAT)
12
+ # ARG 变量仅在编译期有效,不会被打包进最终的运行镜像中,绝对安全
13
+ ARG GH_TOKEN
14
+
15
+ # 🚀 降维打击:利用 Token 动态拼接远程 Private 仓库地址并直接 Clone 整个项目文件
16
+ RUN if [ -z "$GH_TOKEN" ]; then echo "❌ 错误:请在 Hugging Face 设置中配置 GH_TOKEN 密钥!" && exit 1; fi && \
17
+ git clone https://${GH_TOKEN}@github.com/jjf1126/Agent-Platform-Studio.git .
18
+
19
+ # 开始执行标准的依赖下载与项目现场物理编译
20
+ RUN go mod download && \
21
+ CGO_ENABLED=0 go build -buildvcs=false -trimpath -ldflags="-s -w" -o vproxy ./cmd/vproxy \
22
+ && go clean -cache -modcache -testcache
23
+
24
+ # ==========================================
25
+ # 第二阶段:构建最终常驻运行的纯净镜像
26
+ # ==========================================
27
+ FROM alpine:3.20
28
+
29
+ RUN apk add --no-cache ca-certificates tzdata bash
30
+
31
+ WORKDIR /app
32
+
33
+ # 1. 从第一阶段克隆并编译好的目录里,把纯净的主程序捞过来
34
+ COPY --from=builder /build/vproxy /app/vproxy
35
+
36
+ # 2. 🎯 将拉取下来的私有配置文件夹物理复制到运行目录
37
+ COPY --from=builder /build/config/ /app/config/
38
+
39
+ # 3. 锁定环境变量路径
40
+ ENV VPROXY_CONFIG=/app/config/config.json
41
+ ENV VPROXY_API_KEYS=/app/config/api_keys.txt
42
+ ENV VPROXY_MODELS=/app/config/models.json
43
+
44
+ # 4. 强制注入端口适配 Hugging Face 7860 核心网关限制
45
+ ENV PORT=7860
46
+ EXPOSE 7860
47
+
48
+ # 5. 彻底剥夺原厂具有覆盖风险的 entrypoint 脚本,直接以本地文件运行模式启动二进制
49
+ CMD ["./vproxy"]