fix(ops): reconcile CI backend wrapper and gate locked dependency image before swap
Deploy Backend / deploy (push) Successful in 1m17s
Deploy Backend / deploy (push) Successful in 1m17s
This commit is contained in:
1 parent
c2960c4ed0
commit
3fb1e417c6
5 files changed
+108
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# CI-owned backend recovery: no migrations, cleanup, or dependency-container changes.
|
||||
set -euo pipefail
|
||||
APP_DIR=${APP_DIR:-/opt/services/parsa/backend/repo}
|
||||
BASE_COMPOSE=${BASE_COMPOSE:-/opt/services/parsa/backend/compose.yml}
|
||||
EXPECTED=${1:?expected immutable commit required}
|
||||
[[ "$EXPECTED" =~ ^[0-9a-f]{40}$ ]]
|
||||
cd "$APP_DIR"
|
||||
test "$(git rev-parse HEAD)" = "$EXPECTED"
|
||||
test -z "$(git status --porcelain --untracked-files=normal)"
|
||||
export PARSA_BUILD_CONTEXT="$APP_DIR"
|
||||
export PARSA_BACKEND_IMAGE="parsa-backend-ci:$EXPECTED"
|
||||
compose=(docker compose -p backend -f "$BASE_COMPOSE" -f "$APP_DIR/ops/backend.compose.yml")
|
||||
"${compose[@]}" config --quiet
|
||||
"${compose[@]}" build backend
|
||||
# Exercise the autoloader in the built image before touching the current container.
|
||||
docker run --rm --network none --entrypoint php "$PARSA_BACKEND_IMAGE" -r 'require "/var/www/html/vendor/autoload.php"; if (!class_exists("Illuminate\\Foundation\\Application")) { exit(1); }'
|
||||
"${compose[@]}" up -d --no-deps --no-build backend
|
||||
for i in {1..30}; do
|
||||
code=$(curl --max-time 15 -s -o /dev/null -w '%{http_code}' -H 'Accept: application/json' https://backend.parsaaghayi.ir/api/website/about-me/1/translation/en || true)
|
||||
if [ "$code" = 200 ]; then
|
||||
echo "Backend deployed successfully: $EXPECTED (real API HTTP200)"
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
echo "ERROR: real API health gate failed (HTTP ${code:-none})" >&2
|
||||
exit 1
|
||||
Reference in new issue
Block a user