Spaces:
Paused
Paused
Update Dockerfile
Browse files- 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.
|
| 10 |
RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
|
| 11 |
|
| 12 |
-
# 2.
|
| 13 |
-
RUN go mod init omniroute && go
|
| 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 专属端口
|