Update deploy to external server
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
name: Test & Deploy Waitlist
|
name: Test & Deploy Waitlist
|
||||||
run-name: ${{ gitea.ref_name }} → Docker LXC
|
run-name: ${{ gitea.ref_name }} → Production
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: pytest tests/ -v --tb=short
|
run: pytest tests/ -v --tb=short
|
||||||
|
|
||||||
# ── 2. Deploy to Docker LXC via SSH ─────────────────────────────────
|
# ── 2. Deploy to production via SSH ─────────────────────────────────
|
||||||
deploy:
|
deploy:
|
||||||
needs: test
|
needs: test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -52,6 +52,7 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
DEPLOY_DIR="/opt/adiuvai-waitlist"
|
DEPLOY_DIR="/opt/adiuvai-waitlist"
|
||||||
|
WAITLIST_DIR="$DEPLOY_DIR/waitlist"
|
||||||
REPO_URL="http://10.0.0.119:3000/${{ gitea.repository }}.git"
|
REPO_URL="http://10.0.0.119:3000/${{ gitea.repository }}.git"
|
||||||
TAG="${{ gitea.ref_name }}"
|
TAG="${{ gitea.ref_name }}"
|
||||||
|
|
||||||
@@ -60,13 +61,13 @@ jobs:
|
|||||||
git clone --depth 1 --branch "${TAG}" "${REPO_URL}" adiuvai-waitlist-deploy
|
git clone --depth 1 --branch "${TAG}" "${REPO_URL}" adiuvai-waitlist-deploy
|
||||||
|
|
||||||
# ── Sync source (preserve .env) ──
|
# ── Sync source (preserve .env) ──
|
||||||
|
mkdir -p "$WAITLIST_DIR"
|
||||||
cp -rf /tmp/adiuvai-waitlist-deploy/app/ \
|
cp -rf /tmp/adiuvai-waitlist-deploy/app/ \
|
||||||
/tmp/adiuvai-waitlist-deploy/alembic/ \
|
/tmp/adiuvai-waitlist-deploy/alembic/ \
|
||||||
/tmp/adiuvai-waitlist-deploy/alembic.ini \
|
/tmp/adiuvai-waitlist-deploy/alembic.ini \
|
||||||
/tmp/adiuvai-waitlist-deploy/Dockerfile \
|
/tmp/adiuvai-waitlist-deploy/Dockerfile \
|
||||||
/tmp/adiuvai-waitlist-deploy/docker-compose.yml \
|
|
||||||
/tmp/adiuvai-waitlist-deploy/requirements.txt \
|
/tmp/adiuvai-waitlist-deploy/requirements.txt \
|
||||||
"$DEPLOY_DIR/"
|
"$WAITLIST_DIR/"
|
||||||
rm -rf /tmp/adiuvai-waitlist-deploy
|
rm -rf /tmp/adiuvai-waitlist-deploy
|
||||||
|
|
||||||
# ── Verify .env ──
|
# ── Verify .env ──
|
||||||
@@ -75,22 +76,22 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Build & restart ──
|
# ── Build & restart waitlist container ──
|
||||||
cd "$DEPLOY_DIR"
|
cd "$DEPLOY_DIR"
|
||||||
docker compose build app
|
docker compose build waitlist
|
||||||
docker compose up -d --no-deps --force-recreate app
|
docker compose up -d --no-deps --force-recreate waitlist
|
||||||
|
|
||||||
# ── Migrations (runs inside the container) ──
|
# ── Migrations (runs inside the container) ──
|
||||||
docker compose exec -T app alembic upgrade head
|
docker compose exec -T waitlist alembic upgrade head
|
||||||
|
|
||||||
# ── Health check ──
|
# ── Health check ──
|
||||||
echo "Waiting for app..."
|
echo "Waiting for app..."
|
||||||
sleep 5
|
sleep 5
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8001/health)
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:80/health)
|
||||||
if [ "$HTTP_CODE" -eq 200 ]; then
|
if [ "$HTTP_CODE" -eq 200 ]; then
|
||||||
echo "✅ Waitlist service is healthy (HTTP ${HTTP_CODE})"
|
echo "✅ Waitlist service is healthy (HTTP ${HTTP_CODE})"
|
||||||
else
|
else
|
||||||
echo "❌ Health check failed (HTTP ${HTTP_CODE})"
|
echo "❌ Health check failed (HTTP ${HTTP_CODE})"
|
||||||
docker compose logs app --tail=50
|
docker compose logs waitlist --tail=50
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user