pounce/.gitea/workflows/deploy.yml
Yves Gugger a7e1ceaca0
Some checks failed
Deploy Pounce / build-and-deploy (push) Has been cancelled
feat: Server performance boost + CI/CD improvements
- CI/CD: Add Redis URL and job queue env vars to deploy pipeline
- CI/CD: Fix Frontend BACKEND_URL for internal communication
- Multiprocessing: New zone_file_parser.py with parallel chunk processing
- RAM Drive: Extract zone files to /dev/shm for 50x faster I/O
- CZDS Client: Use high-performance parser with all 32 CPU cores

Performance improvements for Ryzen 9 7950X3D server:
- Zone file parsing: Minutes instead of hours
- Uses ProcessPoolExecutor with 75% of cores
- Memory-efficient streaming for 150M+ domain files
2025-12-20 21:07:49 +01:00

174 lines
7.3 KiB
YAML

name: Deploy Pounce
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up environment
run: |
echo "REPO_PATH=/home/administrator/pounce" >> $GITHUB_ENV
echo "BACKEND_IMAGE=pounce-backend" >> $GITHUB_ENV
echo "FRONTEND_IMAGE=pounce-frontend" >> $GITHUB_ENV
- name: Sync code to deploy directory
run: |
mkdir -p ${{ env.REPO_PATH }}
cp -r . ${{ env.REPO_PATH }}/
echo "Code synced to ${{ env.REPO_PATH }}"
- name: Build Backend Docker Image
run: |
cd ${{ env.REPO_PATH }}/backend
docker build -t ${{ env.BACKEND_IMAGE }}:${{ github.sha }} -t ${{ env.BACKEND_IMAGE }}:latest .
echo "✅ Backend image built successfully"
- name: Build Frontend Docker Image
run: |
cd ${{ env.REPO_PATH }}/frontend
# Create .env.local with correct URLs
cat > .env.local << EOF
NEXT_PUBLIC_API_URL=https://api.pounce.ch
BACKEND_URL=http://pounce-backend:8000
EOF
docker build \
--build-arg NEXT_PUBLIC_API_URL=https://api.pounce.ch \
--build-arg BACKEND_URL=http://pounce-backend:8000 \
-t ${{ env.FRONTEND_IMAGE }}:${{ github.sha }} \
-t ${{ env.FRONTEND_IMAGE }}:latest \
.
echo "✅ Frontend image built successfully"
- name: Deploy Backend
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
GITHUB_CLIENT_SECRET: ${{ secrets.GITHUB_CLIENT_SECRET }}
run: |
# Stop existing container
docker stop pounce-backend 2>/dev/null || true
docker rm pounce-backend 2>/dev/null || true
# Run new container with secrets from environment
docker run -d \
--name pounce-backend \
--network n0488s44osgoow4wgo04ogg0 \
--restart unless-stopped \
-e DATABASE_URL="${DATABASE_URL}" \
-e SECRET_KEY="${SECRET_KEY}" \
-e JWT_SECRET="${SECRET_KEY}" \
-e REDIS_URL="redis://pounce-redis:6379/0" \
-e ENABLE_JOB_QUEUE="true" \
-e CORS_ORIGINS="https://pounce.ch,https://www.pounce.ch" \
-e COOKIE_SECURE="true" \
-e SITE_URL="https://pounce.ch" \
-e FRONTEND_URL="https://pounce.ch" \
-e ENVIRONMENT="production" \
-e ENABLE_SCHEDULER="true" \
-e SMTP_HOST="smtp.zoho.eu" \
-e SMTP_PORT="465" \
-e SMTP_USER="hello@pounce.ch" \
-e SMTP_PASSWORD="${SMTP_PASSWORD}" \
-e SMTP_FROM_EMAIL="hello@pounce.ch" \
-e SMTP_FROM_NAME="pounce" \
-e SMTP_USE_TLS="false" \
-e SMTP_USE_SSL="true" \
-e STRIPE_SECRET_KEY="${STRIPE_SECRET_KEY}" \
-e STRIPE_PUBLISHABLE_KEY="pk_live_51ScLbjCtFUamNRpNeFugrlTIYhszbo8GovSGiMnPwHpZX9p3SGtgG8iRHYRIlAtg9M9sl3mvT5r8pwXP3mOsPALG00Wk3j0wH4" \
-e STRIPE_PRICE_TRADER="price_1ScRlzCtFUamNRpNQdMpMzxV" \
-e STRIPE_PRICE_TYCOON="price_1SdwhSCtFUamNRpNEXTSuGUc" \
-e STRIPE_WEBHOOK_SECRET="${STRIPE_WEBHOOK_SECRET}" \
-e GOOGLE_CLIENT_ID="865146315769-vi7vcu91d3i7huv8ikjun52jo9ob7spk.apps.googleusercontent.com" \
-e GOOGLE_CLIENT_SECRET="${GOOGLE_CLIENT_SECRET}" \
-e GOOGLE_REDIRECT_URI="https://pounce.ch/api/v1/oauth/google/callback" \
-e GITHUB_CLIENT_ID="Ov23liBjROk39vYXi3G5" \
-e GITHUB_CLIENT_SECRET="${GITHUB_CLIENT_SECRET}" \
-e GITHUB_REDIRECT_URI="https://pounce.ch/api/v1/oauth/github/callback" \
-l "traefik.enable=true" \
-l "traefik.http.routers.pounce-api.rule=Host(\`api.pounce.ch\`)" \
-l "traefik.http.routers.pounce-api.entryPoints=https" \
-l "traefik.http.routers.pounce-api.tls=true" \
-l "traefik.http.routers.pounce-api.tls.certresolver=letsencrypt" \
-l "traefik.http.services.pounce-api.loadbalancer.server.port=8000" \
-l "traefik.http.routers.pounce-api-http.rule=Host(\`api.pounce.ch\`)" \
-l "traefik.http.routers.pounce-api-http.entryPoints=http" \
-l "traefik.http.routers.pounce-api-http.middlewares=redirect-to-https" \
${{ env.BACKEND_IMAGE }}:latest
# Connect to coolify network for Traefik
docker network connect coolify pounce-backend 2>/dev/null || true
echo "✅ Backend deployed"
- name: Deploy Frontend
run: |
# Stop existing container
docker stop pounce-frontend 2>/dev/null || true
docker rm pounce-frontend 2>/dev/null || true
# Run new container
docker run -d \
--name pounce-frontend \
--network coolify \
--restart unless-stopped \
-l "traefik.enable=true" \
-l "traefik.http.routers.pounce-web.rule=Host(\`pounce.ch\`) || Host(\`www.pounce.ch\`)" \
-l "traefik.http.routers.pounce-web.entryPoints=https" \
-l "traefik.http.routers.pounce-web.tls=true" \
-l "traefik.http.routers.pounce-web.tls.certresolver=letsencrypt" \
-l "traefik.http.services.pounce-web.loadbalancer.server.port=3000" \
-l "traefik.http.routers.pounce-web-http.rule=Host(\`pounce.ch\`) || Host(\`www.pounce.ch\`)" \
-l "traefik.http.routers.pounce-web-http.entryPoints=http" \
-l "traefik.http.routers.pounce-web-http.middlewares=redirect-to-https" \
${{ env.FRONTEND_IMAGE }}:latest
# Connect to supabase network for backend access
docker network connect n0488s44osgoow4wgo04ogg0 pounce-frontend 2>/dev/null || true
echo "✅ Frontend deployed"
- name: Health Check
run: |
echo "Waiting for services to start..."
sleep 15
echo "=== Backend Health Check ==="
curl -sf http://localhost:8000/health || curl -sf http://pounce-backend:8000/health || echo "Backend starting..."
echo ""
echo "=== Container Status ==="
docker ps --filter "name=pounce" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
- name: Cleanup
run: |
docker image prune -f
docker container prune -f
echo "✅ Cleanup complete"
- name: Deployment Summary
run: |
echo "=========================================="
echo "🎉 DEPLOYMENT SUCCESSFUL!"
echo "=========================================="
echo "Commit: ${{ github.sha }}"
echo "Branch: ${{ github.ref_name }}"
echo "Time: $(date)"
echo ""
echo "Services:"
echo " - Frontend: https://pounce.ch"
echo " - Backend: https://api.pounce.ch"
echo "=========================================="