Docker Deployment
Deploy Aya to production using Docker Compose with multi-stage builds for optimized image sizes.Production Compose File
Aya includescompose.production.yml for production deployments:
compose.production.yml
Dockerfile Stages
Frontend Dockerfile
apps/webclient/Dockerfile
Backend Dockerfile
apps/services/Dockerfile
- Multi-stage builds reduce final image size
- Frontend: ~200 MB (from ~1 GB with build dependencies)
- Backend: ~30 MB (distroless base)
- Build cache layers speed up rebuilds
Deployment Steps
Start all services
- PostgreSQL (waits for health check)
- Backend services (depends on postgres)
- Frontend webclient
Reverse Proxy Setup
In production, use a reverse proxy (nginx/Caddy/Traefik) for:- HTTPS/TLS termination
- Rate limiting
- Static file caching
- Load balancing
Nginx Example
/etc/nginx/sites-available/aya.is
Caddy Example (Simpler)
Caddyfile
Health Checks
Implement health check endpoints:Backend health check
Monitoring
Logging
Configure structured JSON logging:Resource Limits
Set CPU and memory limits:Backup Strategy
PostgreSQL Backups
Scaling
Horizontal Scaling
Run multiple frontend/backend instances:Database Optimization
Security Best Practices
Use secrets management
Use secrets management
Don’t put secrets in Create secrets:
compose.yml. Use Docker secrets or external tools:Run as non-root
Run as non-root
Use distroless/minimal base images:Or specify user:
Limit network exposure
Limit network exposure
Only expose necessary ports:
Keep images updated
Keep images updated
Troubleshooting
Container exits immediately
Container exits immediately
Check logs:Common causes:
- Missing environment variables
- Database connection failed
- Port already in use
Out of memory
Out of memory
Increase container memory:
Database connection errors
Database connection errors
Verify PostgreSQL is healthy:
Next Steps
Nix Deployment
Alternative deployment with Nix for reproducibility
Environment Variables
Complete reference for all configuration options
Database Guide
Learn about migrations and backups
Frontend Development
Understand build artifacts and SSR