Deployment Guide
Overview
This guide covers deployment of Lager Guru to production environments using Docker and Nginx.
Prerequisites
- Docker and Docker Compose installed
- Nginx installed (for reverse proxy)
- Domain name configured (optional)
- SSL certificate (for HTTPS)
Docker Deployment
Build and Run
bash
# Build Docker image
docker build -t lager-guru:latest .
# Or use docker-compose
docker compose up -d --buildEnvironment Variables
Create a .env file:
bash
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=your-anon-key
VITE_WEB_PUSH_PUBLIC_KEY=your-vapid-public-keyHealth Check
After deployment, verify the application is running:
bash
curl http://localhost/health.htmlNginx Configuration
Basic Configuration
See deploy/nginx.conf for basic configuration with:
- Security headers
- SPA routing support
- Internal network restrictions
Production Configuration
For production, use deploy/nginx-lager-guru.hashmatrix.de.conf which includes:
- SSL/TLS configuration
- Domain-specific settings
- Optimized caching
Setup Steps
- Copy configuration file:
bash
sudo cp deploy/nginx-lager-guru.hashmatrix.de.conf /etc/nginx/sites-available/lager-guru- Create symbolic link:
bash
sudo ln -s /etc/nginx/sites-available/lager-guru /etc/nginx/sites-enabled/- Test configuration:
bash
sudo nginx -t- Reload Nginx:
bash
sudo systemctl reload nginxCI/CD Deployment
Automated Deployment
Deployment is automated via GitHub Actions when you push a version tag:
bash
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0The CI/CD pipeline will:
- Build Docker image
- Push to GitHub Container Registry
- Deploy to production server
- Run health checks
Manual Deployment
Use the deployment script on the server:
bash
cd /var/www/lager-guru
./scripts/deploy.shServer Setup
Initial Setup
- Clone repository:
bash
git clone https://github.com/your-org/lager-guru.git
cd lager-guruCreate
.envfile with production credentialsStart services:
bash
docker compose up -dUpdating
- Pull latest changes:
bash
git pull origin main- Rebuild and restart:
bash
docker compose up -d --buildMonitoring
Health Checks
Monitor the health endpoint:
bash
curl http://your-domain.com/health.htmlLogs
View Docker logs:
bash
docker compose logs -f lager-guruResource Usage
Check container resources:
bash
docker statsTroubleshooting
Container Won't Start
- Check logs:
docker compose logs lager-guru - Verify environment variables
- Check port availability
- Verify Docker daemon is running
Nginx Errors
- Test configuration:
sudo nginx -t - Check error logs:
sudo tail -f /var/log/nginx/error.log - Verify file permissions
- Check firewall rules
Database Connection Issues
- Verify Supabase credentials in
.env - Check network connectivity
- Verify RLS policies
- Check Supabase dashboard
Security Considerations
Production Checklist
- [ ] HTTPS enabled with valid SSL certificate
- [ ] Security headers configured
- [ ] Environment variables secured
- [ ] Database credentials protected
- [ ] Firewall rules configured
- [ ] Regular backups scheduled
- [ ] Monitoring and alerting set up
Network Security
- Configure allowed IP ranges in Nginx
- Use VPN for internal access
- Implement rate limiting
- Enable DDoS protection
Backup and Recovery
Database Backups
Use the provided backup script:
bash
./scripts/backup-db.shApplication Backups
Backup Docker volumes:
bash
docker run --rm -v lager-guru_data:/data -v $(pwd):/backup alpine tar czf /backup/backup.tar.gz /dataRecovery
Restore from backup:
bash
docker run --rm -v lager-guru_data:/data -v $(pwd):/backup alpine tar xzf /backup/backup.tar.gz -C /Scaling
Horizontal Scaling
- Deploy multiple instances behind load balancer
- Use shared database (Supabase)
- Configure sticky sessions if needed
Vertical Scaling
- Increase container resources
- Optimize database queries
- Add caching layer
Performance Optimization
Caching
- Enable browser caching for static assets
- Use CDN for global distribution
- Implement service worker caching
Database Optimization
- Add appropriate indexes
- Use materialized views for analytics
- Optimize RLS policies
Maintenance
Regular Tasks
- Update dependencies
- Review and rotate credentials
- Monitor resource usage
- Review security logs
- Test backup and recovery
See Maintenance Guide for detailed checklist.