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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -7
Dockerfile CHANGED
@@ -1,26 +1,26 @@
1
  # --- 第一阶段:让云端去 GitHub 抓代码并编译 ---
2
  FROM golang:1.21-alpine AS builder
3
 
4
- # 安装 git 客户端
5
  RUN apk add --no-cache git
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
  # --- 第二阶段:极简运行环境 ---
19
  FROM alpine:latest
20
  RUN apk --no-cache add ca-certificates tzdata
21
  WORKDIR /app
22
 
23
- # 把编译好的程序搬过来
24
  COPY --from=builder /app/omniroute .
25
 
26
  # 锁死 Hugging Face 专属端口
 
1
  # --- 第一阶段:让云端去 GitHub 抓代码并编译 ---
2
  FROM golang:1.21-alpine AS builder
3
 
4
+ # 安装 git
5
  RUN apk add --no-cache git
6
 
7
  WORKDIR /app
8
 
9
+ # 1. 拉取代码
10
  RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
11
 
12
+ # 2. 修正刚打错的命令,并在根录下执行 go mod tidy
13
+ RUN go mod init omniroute && go mod tidy || true
14
 
15
+ # 3. 【核心修复】使用 ./... 自动寻找子目录下的入口文件进递归编译
16
+ RUN CGO_ENABLED=0 GOOS=linux go build -o omniroute ./...
17
 
18
  # --- 第二阶段:极简运行环境 ---
19
  FROM alpine:latest
20
  RUN apk --no-cache add ca-certificates tzdata
21
  WORKDIR /app
22
 
23
+ # 把第一阶段编译好的程序搬过来
24
  COPY --from=builder /app/omniroute .
25
 
26
  # 锁死 Hugging Face 专属端口