c80500f6ac
Also we introduced opencode for code production.
178 lines
5.7 KiB
YAML
178 lines
5.7 KiB
YAML
# prebake.yaml.tmpl
|
||
#
|
||
# 术语说明:
|
||
# 可选:该字段可以不给出
|
||
# 默认为...:隐含“可选”
|
||
# 留空:尚未定义,留作后续
|
||
|
||
# 版本号,用于格式兼容性检查
|
||
version: "1.0"
|
||
|
||
# 构建环境定义
|
||
environment:
|
||
# 构建机类型
|
||
builder: "docker" # 或 "firecracker", "custom", "baremetal"
|
||
|
||
# 构建机配置,注意以下只会出现与上述构建机类型对应的组。
|
||
config:
|
||
# baremetal:
|
||
# 不需要
|
||
|
||
# docker:
|
||
# 镜像名
|
||
image: "rust:1.70-slim"
|
||
# Dockerfile路径,相对于项目根目录,不能与镜像一同指定,两者必须指定其一
|
||
dockerfile: "/Dockerfile"
|
||
# Docker构建参数,可选,只能与dockerfile搭配使用
|
||
build_args:
|
||
- "RUST_VERSION=1.70"
|
||
|
||
# firecracker:
|
||
# 留空,还没做
|
||
|
||
# custom:
|
||
# 自定义构建机名称
|
||
name: "my-custom-builder"
|
||
# 设置脚本,相对于项目根目录
|
||
setup_script: "setup-builder.sh"
|
||
# 清洁脚本,相对于项目根目录
|
||
cleanup_script: "cleanup-builder.sh"
|
||
|
||
# 硬件资源要求,满足最小要求的构建机可以被选中,可选
|
||
resources:
|
||
cpu: 2 # CPU核心数,默认为1
|
||
memory: "2G" # 内存大小,也可以写作2048MB,默认为"1G"
|
||
disk: "10G" # 磁盘空间,也可以写作10240MB,默认为"1G"
|
||
architecture: "x86_64" # 架构要求,只能是"noarch"或{"x86_64"/"amd64", "arm64"/"aarch64", "riscv64", "loongarch64"/"loong64"}中的一个或几个
|
||
gpu: false # 是否需要GPU,默认为false
|
||
gpu_type: "cuda" # GPU类型(如果需要),可以是"cuda", "rocm", "vulkan", "oneapi"中的一个或几个
|
||
tags: # 自定义标签,只有满足标签的构建机可以被选中
|
||
- "custom_tag"
|
||
|
||
# 网络配置,可选
|
||
network:
|
||
enabled: true # 启用网络,对baremetal不适用,默认为true
|
||
outbound: true # 允许出站连接,对baremetal不适用,默认为true
|
||
dns_servers: # 指定构建机的DNS服务器,对baremetal不适用,custom应该自行处理DNS问题,可选
|
||
- "8.8.8.8"
|
||
- "1.1.1.1"
|
||
proxies: # 代理配置,暂时留空,可选
|
||
|
||
# 依赖定义,安装依赖时按custom_pre-system-languages-custom顺序进行,可选
|
||
dependencies:
|
||
# 系统包依赖,按软件包类型给出或any通配,若存在发行版则选择之,否则选中any,也没有则报警告但继续
|
||
system:
|
||
deb:
|
||
packages: # 安装的软件包
|
||
- "git"
|
||
- "curl"
|
||
- "build-essential"
|
||
- "pkg-config"
|
||
- "libssl-dev"
|
||
repositories:
|
||
- "ppa:custom/ppa" # 自定义PPA(Ubuntu)
|
||
mirror: "https://mirrors.tuna.tsinghua.edu.cn" # 指定软件包镜像源,可选
|
||
pacman:
|
||
packages:
|
||
- "git"
|
||
- "curl"
|
||
- "base-devel"
|
||
- "pkg-config"
|
||
- "openssl"
|
||
repositories:
|
||
- "https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch" # 自定义仓库(Arch)
|
||
mirror: "https://mirrors.tuna.tsinghua.edu.cn" # 指定软件包镜像源,可选
|
||
rpm:
|
||
# 略
|
||
|
||
# 语言特定依赖,可选,此处定义不稳定
|
||
languages:
|
||
rust:
|
||
toolchain: "stable-x86_64-unknown-linux-gnu"
|
||
|
||
# 自定义依赖步骤,可选
|
||
custom:
|
||
- name: "install-custom-tool" # 名称
|
||
command: "curl -fsSL https://example.com/install.sh | sh" # 命令
|
||
environment: # 环境变量
|
||
CUSTOM_VAR: "value"
|
||
|
||
- name: "build-native-dep"
|
||
command: "make && make install"
|
||
working_dir: "native-deps" # 工作目录,基于项目根目录
|
||
timeout: 300 # 超时,默认为300秒
|
||
|
||
# 自定义依赖步骤,但是在依赖安装时最先进行,可选
|
||
custom_pre:
|
||
- name: "install-custom-tool"
|
||
command: "curl -fsSL https://example.com/install.sh | sh"
|
||
environment:
|
||
CUSTOM_VAR: "value"
|
||
|
||
- name: "build-native-dep"
|
||
command: "make && make install"
|
||
working_dir: "native-deps"
|
||
timeout: 300
|
||
|
||
# 环境变量配置,可选
|
||
environment_variables:
|
||
# 构建环境变量,只在prebake阶段有效
|
||
prebake:
|
||
RUST_BACKTRACE: "full"
|
||
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
|
||
NODE_ENV: "production"
|
||
|
||
# 运行时环境变量(会传递给bake阶段,与该阶段获取的环境一并作为.env保存)
|
||
bake:
|
||
DATABASE_URL: "postgresql://user:pass@localhost/db"
|
||
LOG_LEVEL: "info"
|
||
__ENV_FILE: ".env" # 特殊变量,指定项目中.env的位置并合并其中的值。该值本身不传入bake阶段
|
||
|
||
# 缓存配置,可选
|
||
cache:
|
||
# 缓存目录
|
||
directories:
|
||
- path: "/usr/local/cargo"
|
||
strategy: "always" # 在"always","readonly","clean"和"never"中选择一个,可以被流水线启动时配置覆盖,默认为"always"
|
||
mode: "zstd" # 在"gzip","zstd","none"和"dir"中选择一个
|
||
|
||
- path: "/root/.npm"
|
||
strategy: "clean"
|
||
mode: "none"
|
||
|
||
- path: "/app/target"
|
||
strategy: "always"
|
||
mode: "dir"
|
||
|
||
# 缓存策略
|
||
strategy:
|
||
ttl_days: 30 # 缓存生存时间
|
||
max_size_gb: 20 # 最大缓存大小
|
||
cleanup_policy: "lru" # 清理策略:lru, fifo, size
|
||
|
||
# 安全配置
|
||
security:
|
||
# 留空
|
||
|
||
# 钩子脚本,可选
|
||
hooks:
|
||
# 依赖安装前
|
||
pre_dependencies:
|
||
- command: "echo 'Starting dependency installation'"
|
||
|
||
# 依赖安装后
|
||
post_dependencies:
|
||
- command: "cargo fetch"
|
||
working_dir: "/app"
|
||
|
||
# 环境准备完成
|
||
ready:
|
||
- command: "echo 'Environment ready for build'"
|
||
|
||
# 元数据
|
||
metadata:
|
||
description: "Rust project build environment"
|
||
maintainer: "team@example.com"
|
||
tags: ["rust", "web", "api"]
|
||
project_type: "rust-cargo"
|