# Quick Deploy Guide Minimal steps to deploy the trivia app to production with Caddy. ## Prerequisites - Linux server with Docker and Docker Compose installed - Domain name pointing to your server (e.g., `trivia.torrtle.co` → your server IP) - Port 80 and 443 open in firewall ## 5-Minute Deploy ### 1. Clone and Configure ```bash # Clone repository git clone cd trivia-thang # Configure environment cp .env.production.example .env.production nano .env.production # Update with your values ``` **Required settings in `.env.production`:** ```bash CORS_ORIGINS=https://trivia.torrtle.co OIDC_ISSUER=https://auth.torrtle.co OIDC_CLIENT_SECRET=your_secret_here OIDC_REDIRECT_URI=https://trivia.torrtle.co/api/auth/callback FRONTEND_URL=https://trivia.torrtle.co SESSION_COOKIE_SECURE=true ``` ### 2. Start Application ```bash # Build and start docker compose -f docker-compose.production.yml up -d # Initialize database docker compose -f docker-compose.production.yml exec backend uv run flask --app backend.app:create_app db upgrade ``` ### 3. Setup Caddy (Automatic HTTPS) ```bash # Install Caddy curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update && sudo apt install caddy # Create minimal Caddyfile sudo tee /etc/caddy/Caddyfile << 'EOF' trivia.torrtle.co { reverse_proxy localhost:5001 } EOF # IMPORTANT: Use localhost:5001, not just :5001 # Start Caddy sudo systemctl restart caddy ``` ### 4. Done! Visit `https://trivia.torrtle.co` - Caddy automatically handles HTTPS! ## Verify Deployment ```bash # Check if app is running curl http://localhost:5001/api/health # Check Docker containers docker compose -f docker-compose.production.yml ps # View logs docker compose -f docker-compose.production.yml logs -f backend ``` ## Common Commands ```bash # Restart application docker compose -f docker-compose.production.yml restart # Update application git pull docker compose -f docker-compose.production.yml up -d --build # View logs docker compose -f docker-compose.production.yml logs -f # Stop application docker compose -f docker-compose.production.yml down ``` ## Troubleshooting ### Can't connect to HTTPS Check Caddy logs: ```bash sudo journalctl -u caddy -f ``` Caddy needs ports 80 and 443 open for Let's Encrypt challenge. ### WebSocket issues Ensure your domain's DNS is properly configured and Caddy is running. Caddy handles WebSocket upgrades automatically. ### Database errors Run migrations: ```bash docker compose -f docker-compose.production.yml exec backend uv run flask --app backend.app:create_app db upgrade ``` --- For detailed documentation, see: - `README.production.md` - Full deployment guide - `Caddyfile.example` - Advanced Caddy configuration - `nginx.conf.example` - Alternative Nginx configuration