Harden deploy workflow and record next-session handoff
This commit is contained in:
+33
-6
@@ -23,19 +23,46 @@ export APP_VERSION="${APP_VERSION:-0.0.0}"
|
||||
export APP_COMMIT_SHA="${APP_COMMIT_SHA:-unknown}"
|
||||
export APP_BUILD_STAMP="${APP_BUILD_STAMP:-unknown}"
|
||||
|
||||
docker compose pull || true
|
||||
docker compose build
|
||||
compose() {
|
||||
docker compose "$@"
|
||||
}
|
||||
|
||||
build_with_recovery() {
|
||||
if compose build; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "docker compose build failed. Attempting one cleanup + retry because layer extraction can fail on constrained hosts."
|
||||
docker image rm -f app-ai-service:latest 2>/dev/null || true
|
||||
docker builder prune -af >/dev/null 2>&1 || true
|
||||
docker system prune -f >/dev/null 2>&1 || true
|
||||
compose build --no-cache ai-service
|
||||
compose build backend frontend
|
||||
}
|
||||
|
||||
compose pull || true
|
||||
build_with_recovery
|
||||
# Force recreation so updated port mappings, env vars, and container config always apply on deploy.
|
||||
docker compose up -d --force-recreate --remove-orphans
|
||||
compose up -d --force-recreate --remove-orphans
|
||||
|
||||
sleep 5
|
||||
docker compose ps
|
||||
compose ps
|
||||
|
||||
backend_status="$(docker compose ps backend --format '{{.State}}' 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')"
|
||||
backend_status="$(compose ps backend --format '{{.State}}' 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')"
|
||||
if [ "$backend_status" != "running" ]; then
|
||||
echo "Backend service is not healthy after deploy (state: ${backend_status:-unknown})."
|
||||
docker compose logs --tail=200 backend || true
|
||||
compose logs --tail=200 backend || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ai_status="$(compose ps ai-service --format '{{.State}}' 2>/dev/null | head -n 1 | tr '[:upper:]' '[:lower:]')"
|
||||
if [ "$ai_status" != "running" ]; then
|
||||
echo "AI service is not healthy after deploy (state: ${ai_status:-unknown})."
|
||||
compose logs --tail=200 ai-service || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up old legacy container name if it still exists from pre-rename deployments.
|
||||
docker rm -f app-summarizer-1 2>/dev/null || true
|
||||
|
||||
echo "Deployment complete: ${APP_VERSION} ${APP_COMMIT_SHA}"
|
||||
|
||||
Reference in New Issue
Block a user