- Single job deployment workflow - Direct Docker build and deploy on server - SSL/HTTPS configuration with Let's Encrypt - Proper Traefik labels for routing - Health checks and cleanup steps
162 lines
6.9 KiB
YAML
162 lines
6.9 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: |
|
|
# Ensure deploy directory exists
|
|
mkdir -p ${{ env.REPO_PATH }}
|
|
|
|
# Sync code (rsync-like behavior with cp)
|
|
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
|
|
docker build \
|
|
--build-arg NEXT_PUBLIC_API_URL=https://api.pounce.ch \
|
|
--build-arg BACKEND_URL=https://api.pounce.ch \
|
|
-t ${{ env.FRONTEND_IMAGE }}:${{ github.sha }} \
|
|
-t ${{ env.FRONTEND_IMAGE }}:latest \
|
|
.
|
|
echo "✅ Frontend image built successfully"
|
|
|
|
- name: Deploy Backend
|
|
run: |
|
|
# Stop existing container
|
|
docker stop pounce-backend 2>/dev/null || true
|
|
docker rm pounce-backend 2>/dev/null || true
|
|
|
|
# Run new container
|
|
docker run -d \
|
|
--name pounce-backend \
|
|
--network n0488s44osgoow4wgo04ogg0 \
|
|
--restart unless-stopped \
|
|
-e DATABASE_URL="postgresql+asyncpg://pounce:PounceDB2024!@supabase-db-n0488s44osgoow4wgo04ogg0:5432/pounce" \
|
|
-e SECRET_KEY="62003b69b382cd55f32aba6301a81039e74a84914505d1bfbf254a97a5ccfb36" \
|
|
-e JWT_SECRET="62003b69b382cd55f32aba6301a81039e74a84914505d1bfbf254a97a5ccfb36" \
|
|
-e CORS_ORIGINS="https://pounce.ch,https://www.pounce.ch,http://pounce.185-142-213-170.sslip.io" \
|
|
-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="CmeR6tk9EaJb" \
|
|
-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="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" \
|
|
-e STRIPE_PUBLISHABLE_KEY="pk_live_51ScLbjCtFUamNRpNeFugrlTIYhszbo8GovSGiMnPwHpZX9p3SGtgG8iRHYRIlAtg9M9sl3mvT5r8pwXP3mOsPALG00Wk3j0wH4" \
|
|
-e STRIPE_PRICE_TRADER="price_1ScRlzCtFUamNRpNQdMpMzxV" \
|
|
-e STRIPE_PRICE_TYCOON="price_1SdwhSCtFUamNRpNEXTSuGUc" \
|
|
-e STRIPE_WEBHOOK_SECRET="whsec_zr1uTZnA7Zylquo0AVNs2g4SHGOFrJRx" \
|
|
-e GOOGLE_CLIENT_ID="865146315769-vi7vcu91d3i7huv8ikjun52jo9ob7spk.apps.googleusercontent.com" \
|
|
-e GOOGLE_CLIENT_SECRET="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" \
|
|
-e GOOGLE_REDIRECT_URI="https://pounce.ch/api/v1/oauth/google/callback" \
|
|
-e GITHUB_CLIENT_ID="Ov23liBjROk39vYXi3G5" \
|
|
-e GITHUB_CLIENT_SECRET="7239bfc61f2f29386655f405524292eabeb76fd2" \
|
|
-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
|
|
|
|
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: |
|
|
# Remove old images
|
|
docker image prune -f
|
|
|
|
# Remove old unused containers
|
|
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 "=========================================="
|