fix: 分离日常发布与首次初始化(09-09-existing-deploy-seed-separation)
这个提交包含在:
@@ -371,7 +371,7 @@ run_logged_deploy_stage "build-init" "${compose_cmd[@]}" build init
|
||||
|
||||
echo ">>> 4.4 预检新配置并执行 init"
|
||||
wait_for_database_health
|
||||
run_logged_deploy_stage "run-init" "${compose_cmd[@]}" run --rm --no-deps -T --entrypoint sh init -lc 'cd /app/server && node -e '\''require("./src/config").getConfig()'\'' && npm run prisma:migrate:deploy && npm run seed:config && npm run seed:trialrun'
|
||||
run_logged_deploy_stage "run-init" "${compose_cmd[@]}" run --rm --no-deps -T -e "DEPLOY_DATA_MODE=$DEPLOY_DATA_MODE" --entrypoint sh init -lc 'cd /app/server && npm run deploy:init'
|
||||
|
||||
echo ">>> 4.5 构建并切换应用服务"
|
||||
wait_for_database_health
|
||||
|
||||
@@ -104,13 +104,11 @@ services:
|
||||
- ./.env
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DEPLOY_DATA_MODE: ${DEPLOY_DATA_MODE:-}
|
||||
BUILD_SHA: ${BUILD_SHA:?set BUILD_SHA to the approved full commit}
|
||||
volumes:
|
||||
- ${STORAGE_HOST_DIR:-./data/storage}:${STORAGE_DIR}
|
||||
entrypoint: ["sh", "-c"]
|
||||
command: >
|
||||
cd /app/server
|
||||
&& npm run prisma:migrate:deploy
|
||||
&& npm run seed:config
|
||||
&& npm run seed:trialrun
|
||||
command:
|
||||
- cd /app/server && npm run deploy:init
|
||||
restart: "no"
|
||||
|
||||
@@ -78,12 +78,12 @@ const deploymentInjectedEnvKeys = new Set(['BUILD_SHA']);
|
||||
const allowedOverrides = {
|
||||
server: ['NODE_ENV', 'BUILD_SHA'],
|
||||
worker: ['NODE_ENV', 'BUILD_SHA', 'SERVE_CLIENT_DIST', 'JOBS_ENABLED'],
|
||||
init: ['NODE_ENV', 'BUILD_SHA'],
|
||||
init: ['NODE_ENV', 'BUILD_SHA', 'DEPLOY_DATA_MODE'],
|
||||
};
|
||||
const requiredRuntimeOverrides = {
|
||||
server: ['BUILD_SHA'],
|
||||
worker: ['BUILD_SHA'],
|
||||
init: ['BUILD_SHA'],
|
||||
init: ['BUILD_SHA', 'DEPLOY_DATA_MODE'],
|
||||
};
|
||||
const requiredBuildArgs = {
|
||||
server: ['BUILD_SHA', 'VITE_BUILD_SHA'],
|
||||
@@ -389,6 +389,11 @@ for (const serviceName of requiredServices) {
|
||||
}
|
||||
}
|
||||
|
||||
const initBlock = extractServiceBlock(composeContent, 'init');
|
||||
if (!initBlock || !initBlock.includes(' DEPLOY_DATA_MODE: ${DEPLOY_DATA_MODE:-}')) {
|
||||
errors.push('init 的 DEPLOY_DATA_MODE 必须显式传入,缺失时为空,禁止默认初始化');
|
||||
}
|
||||
|
||||
const serverBlock = extractServiceBlock(composeContent, 'server');
|
||||
if (!serverBlock || !/^\s{6}-\s*["']127\.0\.0\.1:\$\{APP_HOST_PORT:-3000\}:3000["']\s*$/m.test(serverBlock)) {
|
||||
errors.push('服务 server 必须通过 APP_HOST_PORT 将容器 3000 端口只绑定到宿主回环地址');
|
||||
|
||||
在新工单中引用
屏蔽一个用户