# 构建阶段 FROM rust:1.85-trixie AS builder # Set working directory WORKDIR /app COPY . . # 编译应用 # 使用 --release 模式进行优化 RUN cargo build --release # 运行阶段 FROM gcr.io/distroless/cc-debian12:nonroot # Set working directory WORKDIR /app # 从构建阶段复制编译好的二进制文件 # 请根据实际项目名称修改 'app' COPY --from=builder /app/target/release/app /app/app # Expose port EXPOSE 8080 # 设置运行时的入口点 ENTRYPOINT ["/app/app"]