javaeeduke commited on
Commit
15377ce
·
verified ·
1 Parent(s): 01e6a7a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -6
Dockerfile CHANGED
@@ -6,11 +6,13 @@ RUN apk add --no-cache git
6
 
7
  WORKDIR /app
8
 
9
- # 【核心】让 Hugging Face 替你 GitHub 拿那 5568 个文件
10
  RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
11
 
12
- # 下载依赖并编译
13
- RUN go mod download
 
 
14
  RUN CGO_ENABLED=0 GOOS=linux go build -o omniroute .
15
 
16
  # --- 第二阶段:极简运行环境 ---
@@ -18,14 +20,13 @@ FROM alpine:latest
18
  RUN apk --no-cache add ca-certificates tzdata
19
  WORKDIR /app
20
 
21
- # 把编译好的程序和可能需要的资源拷过来
22
  COPY --from=builder /app/omniroute .
23
- # 如果官方仓库里有其它的必要文件夹(比如静态资源、配置),云端也一并拷过去:
24
- # COPY --from=builder /app/config ./config
25
 
26
  # 锁死 Hugging Face 专属端口
27
  ENV PORT=7860
28
  ENV OMNIROUTE_PORT=7860
29
  EXPOSE 7860
30
 
 
31
  CMD ["./omniroute"]
 
6
 
7
  WORKDIR /app
8
 
9
+ # 1. 让 Hugging Face 自动拉取那 5568 个文件
10
  RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
11
 
12
+ # 2. 【核心修复】因为原项目缺少 go.mod,我们现场初始化一个模块并自动抓取依赖
13
+ RUN go mod init omniroute && go i get ./... || true
14
+
15
+ # 3. 强行把所有源码编译成静态二进制文件
16
  RUN CGO_ENABLED=0 GOOS=linux go build -o omniroute .
17
 
18
  # --- 第二阶段:极简运行环境 ---
 
20
  RUN apk --no-cache add ca-certificates tzdata
21
  WORKDIR /app
22
 
23
+ # 把编译好的程序过来
24
  COPY --from=builder /app/omniroute .
 
 
25
 
26
  # 锁死 Hugging Face 专属端口
27
  ENV PORT=7860
28
  ENV OMNIROUTE_PORT=7860
29
  EXPOSE 7860
30
 
31
+ # 启动微服务
32
  CMD ["./omniroute"]