feat(k8s): 新增 core 真应用(前端+Django API+Celery worker)构建与部署

- core/frontend: Vite 多阶段镜像 + nginx 同源反代 /api,/admin,/static(零 CORS)
- core/backend: Django gunicorn 镜像 + entrypoint(自动 migrate/collectstatic)+ WhiteNoise
- k8s/core: api/worker/web Deployment+Service + ingress(airshelf-web.airlabs.art)
- workflow: 追加 core 前后端 build/push,从 core/backend/.env 套生产覆盖生成 env Secret 后部署
- .gitignore 放行 core/backend/.env;.env 白名单加入 airshelf-web 域名
- 含前端 WIP 还原改动

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-06-05 10:21:41 +08:00
co-authored by Claude Opus 4.8
parent cfdcd84a30
commit d41e487f08
37 changed files with 4108 additions and 456 deletions
+10 -3
View File
@@ -34,7 +34,7 @@ function readPng(file) {
return PNG.sync.read(fs.readFileSync(file));
}
async function preparePage(page, url, shouldClearStorage) {
async function preparePage(page, url, shouldClearStorage, token) {
await page.goto(url, { waitUntil: "networkidle" });
if (shouldClearStorage) {
await page.evaluate(() => {
@@ -43,6 +43,12 @@ async function preparePage(page, url, shouldClearStorage) {
});
await page.goto(url, { waitUntil: "networkidle" });
}
// 注入登录 token,让受保护的真 React 路由 + /exact 镜像都能 hydrate 同一份真实数据
if (token) {
await page.evaluate((value) => localStorage.setItem("airshelf_token", value), token);
await page.goto(url, { waitUntil: "networkidle" });
await page.waitForTimeout(900); // 等异步数据 hydrate 落定
}
await page.evaluate(async () => {
if ("fonts" in document) await document.fonts.ready;
});
@@ -65,6 +71,7 @@ const viewport = parseViewport(arg("viewport", "1440x900"));
const outDir = path.resolve(repoRoot, arg("out", "core/qa/visual-parity/output"));
const threshold = Number.parseFloat(arg("threshold", "0.03"));
const clearTargetStorage = boolArg("clear-target-storage");
const token = arg("token", "");
fs.mkdirSync(outDir, { recursive: true });
@@ -84,8 +91,8 @@ const targetPath = path.join(outDir, `${name}.implementation.png`);
const diffPath = path.join(outDir, `${name}.diff.png`);
const reportPath = path.join(outDir, `${name}.report.json`);
await preparePage(sourcePage, source, false);
await preparePage(targetPage, target, clearTargetStorage);
await preparePage(sourcePage, source, false, token);
await preparePage(targetPage, target, clearTargetStorage, token);
await sourcePage.screenshot({ path: sourcePath, fullPage: false });
await targetPage.screenshot({ path: targetPath, fullPage: false });