fix(deploy): gate Stage v4 rollout on schema-first maintenance and acceptance

This commit is contained in:
devops committed 2026-10-22 19:18:50 +00:00
1 parent ac065fa911
commit 795bbb33cf
7 files changed
+179 -43

No files matched your search

+11 -43
View File
@@ -1,22 +1,13 @@
#!/bin/bash
set -e
# Explicit no-data-write stage rollout. Run only after testing and pushing HEAD.
if [ "${2:-}" = "stage-backend-only" ]; then
[ "${1:-}" = "develop" ] || exit 2
cd /opt/services/canina/stage
exec 9>/opt/services/canina/stage-backend-deploy.lock
flock -n 9 || { echo "Stage deployment already in progress"; exit 1; }
[ "$(git branch --show-current)" = develop ]
git fetch origin develop
[ "$(git rev-parse HEAD)" = "$(git rev-parse origin/develop)" ]
git diff --quiet -- backend scripts/compose.stage.yml scripts/deploy.sh
# Read tracked compose directly; preserve generated config and nginx.
docker compose -p stage -f scripts/compose.stage.yml --project-directory . build backend_stage
docker compose -p stage -f scripts/compose.stage.yml --project-directory . up -d --no-deps --remove-orphans backend_stage
exit 0
set -euo pipefail
# CI/CD-only Stage rollout; Production awaits separate reviewed authorization.
if [ "${GITHUB_ACTIONS:-${GITEA_ACTIONS:-}}" != true ] || [ "${1:-}" != develop ] || [ "$#" != 1 ]; then
echo 'ERROR: refusing deployment outside CI/CD Stage rollout' >&2
exit 2
fi
# END ROLLOUT GUARD
exec 9>/opt/services/canina/stage-backend-deploy.lock
flock -n 9 || { echo 'Stage deployment already in progress' >&2; exit 1; }
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
@@ -125,32 +116,9 @@ docker compose --progress plain build \
--build-arg VITE_API_URL="${API_URL}" \
${NPM_REGISTRY_ARG}
echo "Building support-chat bot image from committed source..."
BOT_IMAGE="canina-support-bot:${BRANCH}"
DOCKER_BUILDKIT=0 docker build --pull=false -f scripts/support-chat/Dockerfile -t "${BOT_IMAGE}" .
BOT_ENV="${TARGET_DIR}/.support-bot.runtime.env"
docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' canina-bot > "${BOT_ENV}"
chmod 600 "${BOT_ENV}"
echo "Starting containers..."
docker compose up -d --remove-orphans
echo "Starting support-chat bot container..."
docker rm -f canina-bot >/dev/null 2>&1 || true
docker run -d --name canina-bot --restart unless-stopped --env-file "${BOT_ENV}" -e HERMES_HOME=/opt/data -e HERMES_RUNTIME_DIR=/opt/hermes/tools -e API_SERVER_HOST=0.0.0.0 -e API_SERVER_PORT=8642 --network traefik_public -v canina_bot_data:/opt/data "${BOT_IMAGE}" gateway run
docker network connect --ip 172.22.0.15 vpn_net canina-bot
rm -f "${BOT_ENV}"
echo "Waiting for backend to start..."
sleep 15
# Apply committed Prisma migrations as part of the CI/CD deployment.
# This is intentionally migrate deploy (not db push): it is repeatable,
# fail-closed, and applies only migrations already reviewed and committed.
echo "Applying committed database migrations..."
if [ "$BRANCH" = "main" ]; then
docker exec -e PRISMA_HIDE_UPDATE_MESSAGE=true "${CONTAINER_PREFIX}" npx prisma migrate resolve --applied 20261013210253_add_admin_modules >/dev/null 2>&1 || true
fi
docker exec -e PRISMA_HIDE_UPDATE_MESSAGE=true "${CONTAINER_PREFIX}" npx prisma migrate deploy
# Code-only deployment: seed and destructive data changes are not performed here.
# Never recreate the shared Production support bot during a Stage rollout.
source scripts/rollout-stage.sh
stage_rollout
# Auto-cleanup old docker builder cache to keep disk healthy (keeps latest 6GB)
echo "Cleaning up old docker build cache..."