Split production cargo caches by component

This commit is contained in:
2026-05-02 21:16:54 +08:00
parent d48916157b
commit e61b1a1586
3 changed files with 30 additions and 14 deletions

View File

@@ -264,20 +264,34 @@ Jenkins 在 agent 上执行构建时会为不同 Job 或不同构建创建独立
如果构建 agent 使用 `root` 账户执行,缓存目录不应写死为 `/var/lib/jenkins`。推荐优先使用单独数据盘,例如 `/data/jenkins-cache/genarrative/`;如果没有数据盘,可使用 `/var/cache/genarrative-build/`
```bash
mkdir -p /var/cache/genarrative-build/{cargo-home,cargo-target,sccache}
mkdir -p /var/cache/genarrative-build/{api-server,stdb-module}
chmod 700 /var/cache/genarrative-build
```
Rust 构建流水线建议统一设置:
API 构建流水线建议设置:
```groovy
environment {
CARGO_HOME = '/var/cache/genarrative-build/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/cargo-target/prod-release'
CARGO_HOME = '/var/cache/genarrative-build/api-server/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/api-server/cargo-target/prod-release'
CARGO_INCREMENTAL = '0'
RUSTC_WRAPPER = 'sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/api-server/sccache'
SCCACHE_CACHE_SIZE = '30G'
}
```
Stdb module 构建流水线建议设置:
```groovy
environment {
CARGO_HOME = '/var/cache/genarrative-build/stdb-module/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/stdb-module/cargo-target/prod-release'
CARGO_INCREMENTAL = '0'
RUSTC_WRAPPER = 'sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/stdb-module/sccache'
SCCACHE_CACHE_SIZE = '30G'
}
```
@@ -286,16 +300,18 @@ environment {
```groovy
environment {
CARGO_HOME = '/data/jenkins-cache/genarrative/cargo-home'
CARGO_TARGET_DIR = '/data/jenkins-cache/genarrative/cargo-target/prod-release'
CARGO_HOME = '/data/jenkins-cache/genarrative/<component>/cargo-home'
CARGO_TARGET_DIR = '/data/jenkins-cache/genarrative/<component>/cargo-target/prod-release'
CARGO_INCREMENTAL = '0'
RUSTC_WRAPPER = 'sccache'
SCCACHE_DIR = '/data/jenkins-cache/genarrative/sccache'
SCCACHE_DIR = '/data/jenkins-cache/genarrative/<component>/sccache'
SCCACHE_CACHE_SIZE = '30G'
}
```
其中 `<component>` 使用 `api-server``stdb-module`。API 与 Stdb module 并行构建时不能共享同一个 `CARGO_HOME``CARGO_TARGET_DIR`,否则容易在 Cargo package cache 或 target 目录上出现 `Blocking waiting for file lock on package cache` 等锁等待。
`scripts/build-production-release.sh` 必须尊重 `CARGO_TARGET_DIR`,不能硬编码从 `server-rs/target/` 拷贝 Rust 产物。脚本中的产物路径应按以下口径计算:
```bash

View File

@@ -11,11 +11,11 @@ pipeline {
environment {
GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git'
CARGO_HOME = '/var/cache/genarrative-build/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/cargo-target/prod-release'
CARGO_HOME = '/var/cache/genarrative-build/api-server/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/api-server/cargo-target/prod-release'
CARGO_INCREMENTAL = '0'
RUSTC_WRAPPER = 'sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/api-server/sccache'
SCCACHE_CACHE_SIZE = '30G'
}

View File

@@ -11,11 +11,11 @@ pipeline {
environment {
GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git'
CARGO_HOME = '/var/cache/genarrative-build/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/cargo-target/prod-release'
CARGO_HOME = '/var/cache/genarrative-build/stdb-module/cargo-home'
CARGO_TARGET_DIR = '/var/cache/genarrative-build/stdb-module/cargo-target/prod-release'
CARGO_INCREMENTAL = '0'
RUSTC_WRAPPER = 'sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/sccache'
SCCACHE_DIR = '/var/cache/genarrative-build/stdb-module/sccache'
SCCACHE_CACHE_SIZE = '30G'
}