# ========================================== # 阶段 1: 编译 Rust 后端 # ========================================== FROM rust:1.78-slim AS backend-builder WORKDIR /app # 【核心修复】在安装列表中加上 curl,供 utoipa-swagger-ui 编译时下载前端包 RUN apt-get update && apt-get install -y pkg-config libssl-dev git openssl libclang-dev clang curl && rm -rf /var/lib/apt/lists/* # 1. 克隆源码并平铺到 /app 根目录 RUN git clone https://github.com/taichuy/1flowbase.git . # 2. 切进 api/ 子目录进行 Rust 编译 WORKDIR /app/api RUN cargo build --release -p api-server --bin api-server RUN cargo build --release -p plugin-runner --bin plugin-runner # ========================================== # 阶段 2: 构建 Node 前端 # ========================================== FROM node:24-slim AS frontend-builder WORKDIR /app RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* RUN corepack enable && corepack prepare pnpm@latest --activate # 1. 同样克隆源码并平铺到 /app RUN git clone https://github.com/taichuy/1flowbase.git . # 2. 切进 web/ 子目录安装前端依赖 WORKDIR /app/web RUN pnpm install --frozen-lockfile # ========================================== # 阶段 3: 最终运行环境 # ========================================== FROM node:24-slim AS runner WORKDIR /app # 安装 Caddy 反向代理 RUN apt-get update && apt-get install -y caddy debian-keyring debian-archive-keyring apt-transport-https curl && rm -rf /var/lib/apt/lists/* RUN corepack enable && corepack prepare pnpm@latest --activate # 1. 把包含完整 web 源码和 node_modules 的主目录直接拷过来 COPY --from=frontend-builder /app /app # 2. 从后端编译器的 api/target 路径下把二进制文件拎出来,放到根目录 COPY --from=backend-builder /app/api/target/release/api-server /app/api-server COPY --from=backend-builder /app/api/target/release/plugin-runner /app/plugin-runner # 3. 载入你在 Hugging Face 根目录上传的两个配置文件 COPY Caddyfile /app/Caddyfile COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh # 暴露 Hugging Face 唯一的 7860 端口 EXPOSE 7860 ENTRYPOINT ["/app/entrypoint.sh"]