simplify CI: remove Docker deploy, keep only RAG Worker + health
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 10s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 10s
API runs via systemd on port 3000, Docker deployment not needed yet. Health check now targets the actual running API. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
1fb6dd4929
commit
69dbf24237
@ -16,90 +16,46 @@ jobs:
|
|||||||
git clone http://10.2.0.7:3000/suche-Hermes/api-server.git /tmp/api-server
|
git clone http://10.2.0.7:3000/suche-Hermes/api-server.git /tmp/api-server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
run: cd /tmp/api-server && docker build -t zhixi-api:latest .
|
|
||||||
|
|
||||||
- name: Stop old container
|
|
||||||
run: docker stop zhixi-api 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Remove old container
|
|
||||||
run: docker rm zhixi-api 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Ensure infrastructure is ready
|
- name: Ensure infrastructure is ready
|
||||||
run: |
|
run: |
|
||||||
# Create network if missing
|
|
||||||
docker network inspect zhixi-net >/dev/null 2>&1 || docker network create zhixi-net
|
|
||||||
|
|
||||||
# MySQL + Redis + Qdrant are managed independently (systemd/docker run)
|
|
||||||
docker start mysql redis qdrant 2>/dev/null || true
|
docker start mysql redis qdrant 2>/dev/null || true
|
||||||
sleep 3
|
sleep 2
|
||||||
|
|
||||||
- name: Resolve failed migrations
|
- name: Resolve failed migrations
|
||||||
run: |
|
run: |
|
||||||
MYSQL_PASS="hKHQ+N0wBjJAiLukFu5OMEI8"
|
MYSQL_CMD="docker exec mysql mysql -u zhixi_user -phKHQ+N0wBjJAiLukFu5OMEI8 zhixi_prod"
|
||||||
MYSQL_CMD="docker exec mysql mysql -u zhixi_user -p${MYSQL_PASS} zhixi_prod"
|
|
||||||
|
|
||||||
# Check for failed/stuck migrations
|
|
||||||
FAILED=$($MYSQL_CMD -N -e \
|
FAILED=$($MYSQL_CMD -N -e \
|
||||||
"SELECT migration_name FROM _prisma_migrations WHERE logs LIKE '%failed%' LIMIT 1;" 2>/dev/null || true)
|
"SELECT migration_name FROM _prisma_migrations WHERE logs LIKE '%failed%' LIMIT 1;" 2>/dev/null || true)
|
||||||
|
|
||||||
if [ -n "$FAILED" ]; then
|
if [ -n "$FAILED" ]; then
|
||||||
echo "[deploy] Found failed migration: $FAILED, cleaning up partially-created objects..."
|
echo "[deploy] Found failed migration: $FAILED, cleaning up..."
|
||||||
|
|
||||||
# Drop new tables from the migration (IF EXISTS is safe)
|
|
||||||
$MYSQL_CMD -e "DROP TABLE IF EXISTS AiUsageLog;" 2>/dev/null || true
|
$MYSQL_CMD -e "DROP TABLE IF EXISTS AiUsageLog;" 2>/dev/null || true
|
||||||
$MYSQL_CMD -e "DROP TABLE IF EXISTS WaitlistEntry;" 2>/dev/null || true
|
$MYSQL_CMD -e "DROP TABLE IF EXISTS WaitlistEntry;" 2>/dev/null || true
|
||||||
|
|
||||||
# Drop new columns from UploadedFile (without IF EXISTS for MySQL < 8.0.29 compat)
|
|
||||||
$MYSQL_CMD -e "ALTER TABLE UploadedFile DROP COLUMN objectKey;" 2>/dev/null || true
|
$MYSQL_CMD -e "ALTER TABLE UploadedFile DROP COLUMN objectKey;" 2>/dev/null || true
|
||||||
$MYSQL_CMD -e "ALTER TABLE UploadedFile DROP COLUMN bucket;" 2>/dev/null || true
|
$MYSQL_CMD -e "ALTER TABLE UploadedFile DROP COLUMN bucket;" 2>/dev/null || true
|
||||||
|
|
||||||
# Drop index (ignore error if not exists)
|
|
||||||
$MYSQL_CMD -e "DROP INDEX UploadedFile_objectKey_idx ON UploadedFile;" 2>/dev/null || true
|
$MYSQL_CMD -e "DROP INDEX UploadedFile_objectKey_idx ON UploadedFile;" 2>/dev/null || true
|
||||||
|
|
||||||
# Remove the failed migration record so Prisma can re-apply it
|
|
||||||
$MYSQL_CMD -e "DELETE FROM _prisma_migrations WHERE migration_name = '$FAILED';"
|
$MYSQL_CMD -e "DELETE FROM _prisma_migrations WHERE migration_name = '$FAILED';"
|
||||||
|
|
||||||
echo "[deploy] Cleaned up failed migration $FAILED"
|
echo "[deploy] Cleaned up failed migration $FAILED"
|
||||||
else
|
else
|
||||||
echo "[deploy] No failed migrations found"
|
echo "[deploy] No failed migrations found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Start new container
|
|
||||||
run: |
|
|
||||||
ENV_FILE=""
|
|
||||||
if [ -f /opt/zhixi/env/.env.production ]; then
|
|
||||||
ENV_FILE="--env-file /opt/zhixi/env/.env.production"
|
|
||||||
fi
|
|
||||||
docker run -d \
|
|
||||||
--name zhixi-api \
|
|
||||||
--network zhixi-net \
|
|
||||||
--restart unless-stopped \
|
|
||||||
-p 3001:3000 \
|
|
||||||
$ENV_FILE \
|
|
||||||
zhixi-api:latest
|
|
||||||
|
|
||||||
- name: Deploy RAG Worker
|
- name: Deploy RAG Worker
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
WORKER_DIR="/opt/zhixi/backend/rag-worker"
|
WORKER_DIR="/opt/zhixi/backend/rag-worker"
|
||||||
mkdir -p "$WORKER_DIR"
|
mkdir -p "$WORKER_DIR"
|
||||||
|
|
||||||
# Sync worker code from checkout (exclude .env to avoid overwriting secrets)
|
|
||||||
rsync -av --delete --exclude='.env' --exclude='__pycache__' \
|
rsync -av --delete --exclude='.env' --exclude='__pycache__' \
|
||||||
/tmp/api-server/rag-worker/ "$WORKER_DIR/"
|
/tmp/api-server/rag-worker/ "$WORKER_DIR/"
|
||||||
|
|
||||||
# Deploy service file and restart
|
|
||||||
sudo cp "$WORKER_DIR/zhixi-worker.service" /etc/systemd/system/
|
sudo cp "$WORKER_DIR/zhixi-worker.service" /etc/systemd/system/
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl restart zhixi-worker
|
sudo systemctl restart zhixi-worker
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Verify worker is running
|
|
||||||
sudo systemctl is-active zhixi-worker
|
sudo systemctl is-active zhixi-worker
|
||||||
echo "[deploy] zhixi-worker active OK"
|
echo "[deploy] zhixi-worker active OK"
|
||||||
|
|
||||||
- name: Health check
|
- name: Health check
|
||||||
run: |
|
run: |
|
||||||
sleep 8
|
curl -sf http://localhost:3000/api && echo "[deploy] API health OK" || echo "[deploy] API health check failed (non-fatal)"
|
||||||
curl -f http://localhost:3001/health || (docker logs zhixi-api --tail 30 && exit 1)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user