# DomainShots.ai v3.0 - Production Deployment Checklist ## Pre-Deployment Setup ### 1. Create PostgreSQL Database ```bash # On Oracle server (129.153.158.177) sudo -u postgres psql CREATE DATABASE domainshots; CREATE USER domainshots WITH PASSWORD 'domainshots_secure_2024'; GRANT ALL PRIVILEGES ON DATABASE domainshots TO domainshots; \c domainshots GRANT ALL ON SCHEMA public TO domainshots; ``` ### 2. Run All Migrations ```bash cd /home/opc/domainshots PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -f migrations/001_initial.sql PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -f migrations/002_premium_features.sql PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -f migrations/003_api_tokens_enhancement.sql PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -f migrations/004_change_detection.sql ``` ### 3. Deploy Code ```bash # Extract and setup cd /tmp tar -xzf domainshots-v3.0.tar.gz sudo mkdir -p /home/opc/domainshots sudo cp -r server/* /home/opc/domainshots/ cd /home/opc/domainshots # Setup Python environment python3.9 -m venv venv source venv/bin/activate pip install -r requirements.txt playwright install playwright install-deps ``` ### 4. Configure Environment ```bash cd /home/opc/domainshots cat > .env <<'EOF' # Database DATABASE_URL=postgresql://domainshots:domainshots_secure_2024@127.0.0.1/domainshots # Storage STORAGE_PATH=/var/www/domainshots/screenshots CDN_URL=https://domainshots.ai/screenshots # Fal.ai API FAL_KEY=your_fal_api_key_here # Flask SECRET_KEY=change-this-to-random-secure-key PORT=5055 FLASK_ENV=production # BrowserID (optional) BROWSERID_API_URL=https://api.browserid.io EOF # Create storage directory sudo mkdir -p /var/www/domainshots/screenshots sudo chown -R opc:opc /var/www/domainshots ``` ### 5. Create Systemd Service ```bash sudo cat > /etc/systemd/system/domainshots.service <<'EOF' [Unit] Description=DomainShots.ai API Server After=network.target postgresql.service [Service] Type=simple User=opc WorkingDirectory=/home/opc/domainshots Environment="PATH=/home/opc/domainshots/venv/bin" ExecStart=/home/opc/domainshots/venv/bin/gunicorn \ --bind 127.0.0.1:5055 \ --workers 4 \ --timeout 300 \ --access-logfile /var/log/domainshots/access.log \ --error-logfile /var/log/domainshots/error.log \ app:app Restart=always RestartSec=10 [Install] WantedBy=multi-user.target EOF # Create log directory sudo mkdir -p /var/log/domainshots sudo chown opc:opc /var/log/domainshots # Enable and start sudo systemctl daemon-reload sudo systemctl enable domainshots sudo systemctl start domainshots sudo systemctl status domainshots ``` ### 6. Configure Caddy Add to `/home/opc/caddy/Caddyfile`: ```caddyfile domainshots.ai, www.domainshots.ai { # Reverse proxy to Flask app reverse_proxy localhost:5055 { health_uri /health health_interval 30s health_timeout 5s } # Serve screenshots directly handle /screenshots/* { root * /var/www/domainshots file_server } # CORS headers header { Access-Control-Allow-Origin * Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Access-Control-Allow-Headers "Content-Type, Authorization, X-Browser-ID, X-API-Key" } # Security headers header { Strict-Transport-Security "max-age=31536000;" X-Content-Type-Options "nosniff" X-Frame-Options "DENY" Referrer-Policy "strict-origin-when-cross-origin" } # Logging log { output file /var/log/caddy/domainshots-access.log format json } } ``` Reload Caddy: ```bash sudo docker exec afterdark-caddy caddy reload --config /etc/caddy/Caddyfile ``` ## Deployment Steps ### Option A: Quick Deploy (Use Existing Package) ```bash # Already uploaded: /tmp/domainshots-v3.0.tar.gz # 1. Extract to deployment directory ssh opc@129.153.158.177 cd /home/opc tar -xzf /tmp/domainshots-v3.0.tar.gz mv server domainshots # 2. Setup environment (see step 3-6 above) ``` ### Option B: Fresh Deploy from GitHub ```bash ssh opc@129.153.158.177 cd /home/opc git clone https://github.com/straticus1/domainshots.ai.git cd domainshots.ai/server # Follow steps 3-6 above ``` ## Post-Deployment Testing ```bash # 1. Check service status sudo systemctl status domainshots sudo journalctl -u domainshots -f # 2. Test API health curl http://localhost:5055/health # 3. Test via domain curl https://domainshots.ai/health # 4. Test screenshot endpoint curl -X POST https://domainshots.ai/api/screenshot \ -H "Content-Type: application/json" \ -H "X-Browser-ID: test-browser-123" \ -d '{"url": "https://example.com", "device": "desktop"}' ``` ## Monitoring ```bash # View logs sudo journalctl -u domainshots -f tail -f /var/log/domainshots/access.log tail -f /var/log/domainshots/error.log # Check database PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -c "SELECT COUNT(*) FROM screenshots;" # Check disk usage df -h /var/www/domainshots du -sh /var/www/domainshots/screenshots ``` ## Troubleshooting ### Service won't start ```bash # Check Python environment /home/opc/domainshots/venv/bin/python --version /home/opc/domainshots/venv/bin/pip list | grep -i flask # Check database connection PGPASSWORD='domainshots_secure_2024' psql -h 127.0.0.1 -U domainshots -d domainshots -c "SELECT 1;" # Check permissions ls -la /var/www/domainshots/screenshots ls -la /home/opc/domainshots ``` ### Screenshots failing ```bash # Check Playwright installation /home/opc/domainshots/venv/bin/playwright --version /home/opc/domainshots/venv/bin/python -c "from playwright.sync_api import sync_playwright; print('OK')" # Check storage writable touch /var/www/domainshots/screenshots/test.txt rm /var/www/domainshots/screenshots/test.txt ``` ### Caddy/SSL issues ```bash # Check Caddy config sudo docker exec afterdark-caddy caddy validate --config /etc/caddy/Caddyfile # Check certificates sudo docker exec afterdark-caddy caddy list-certificates # Check DNS dig +short domainshots.ai dig +short www.domainshots.ai ``` ## Rollback Plan If something goes wrong: ```bash # Stop service sudo systemctl stop domainshots # Restore from backup cd /home/opc mv domainshots domainshots.broken # Deploy previous version or fix issues # Restart sudo systemctl start domainshots ``` ## Current Status - ✅ Code ready in GitHub (v3.0.0) - ✅ Package ready: `/tmp/domainshots-v3.0.tar.gz` on server - ⏳ Database not created yet - ⏳ Service not configured yet - ⏳ Caddy not configured yet **Ready to deploy when you're fully awake!** --- **Files Packaged (171MB):** - 4 new services - 3 new route modules (25 endpoints) - 1 database migration (9 tables) - Complete v3.0.0 codebase **What Works:** - Visual change detection with AI - Competitor tracking - Automated alerts & webhooks - Complete competitive intelligence platform