Deployment
Learn how to deploy Pillow to production environments with Docker, Kubernetes, and cloud platforms.
Overview
Section titled “Overview”Pillow supports multiple deployment strategies:
- Docker Compose for simple deployments
- Kubernetes for scalable production deployments
- Cloud platforms (AWS, GCP, Azure)
- Traditional server deployments
Docker Deployment
Section titled “Docker Deployment”Production Docker Compose
Section titled “Production Docker Compose”services: mill: image: pillow/mill:latest environment: - MILL_DATABASE_POSTGRES_HOST=postgres - MILL_DATABASE_POSTGRES_PORT=5432 - MILL_DATABASE_POSTGRES_USER=${POSTGRES_USER} - MILL_DATABASE_POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - MILL_DATABASE_POSTGRES_DATABASE=${POSTGRES_DB} ports: - "4000:4000" depends_on: postgres: condition: service_healthy redis: condition: service_healthy
postgres: image: postgis/postgis:16-3.4 environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] interval: 10s timeout: 5s retries: 5
redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5
redpanda: image: redpandadata/redpanda:latest ports: - "19092:19092" volumes: - redpanda_data:/var/lib/redpanda/data
volumes: postgres_data: redis_data: redpanda_data:Deploy with Docker Compose
Section titled “Deploy with Docker Compose”# Set environment variablesexport POSTGRES_DB=pillowexport POSTGRES_USER=pillowexport POSTGRES_PASSWORD=secure_password
# Deploydocker compose -f docker-compose.prod.yml up -dKubernetes Deployment
Section titled “Kubernetes Deployment”Basic Kubernetes Setup
Section titled “Basic Kubernetes Setup”apiVersion: apps/v1kind: Deploymentmetadata: name: pillow-millspec: replicas: 3 selector: matchLabels: app: pillow-mill template: metadata: labels: app: pillow-mill spec: containers: - name: mill image: pillow/mill:latest ports: - containerPort: 4000 env: - name: DATABASE_URL valueFrom: secretKeyRef: name: pillow-secrets key: database-url---apiVersion: v1kind: Servicemetadata: name: pillow-mill-servicespec: selector: app: pillow-mill ports: - protocol: TCP port: 80 targetPort: 4000 type: LoadBalancerCloud Deployments
Section titled “Cloud Deployments”AWS Deployment
Section titled “AWS Deployment”Deploy using AWS ECS or EKS:
# Using AWS CLI and ECSaws ecs create-cluster --cluster-name pillowaws ecs create-service --cluster pillow --service-name pillow-millGoogle Cloud Platform
Section titled “Google Cloud Platform”Deploy using Cloud Run or GKE:
# Using gcloud CLIgcloud run deploy pillow-mill --image gcr.io/PROJECT_ID/pillow-millDeploy using Container Instances or AKS:
# Using Azure CLIaz container create --resource-group pillow-rg --name pillow-mill --image pillow/mill:latestEnvironment Configuration
Section titled “Environment Configuration”Production Environment Variables
Section titled “Production Environment Variables”NODE_ENV=productionMILL_DATABASE_POSTGRES_HOST=your-db-hostMILL_DATABASE_POSTGRES_PORT=5432MILL_DATABASE_POSTGRES_USER=your_userMILL_DATABASE_POSTGRES_PASSWORD=your_secure_passwordMILL_DATABASE_POSTGRES_DATABASE=pillowMILL_DATABASE_POSTGRES_SSL_MODE=requireMILL_REDIS_HOST=your-redis-hostMILL_REDIS_PORT=6379MILL_AUTH_JWT_SECRET=your-super-secure-secretMILL_SERVER_PORT=4000MILL_LOGGING_LEVEL=infoSecurity Considerations
Section titled “Security Considerations”- Use secrets management (AWS Secrets Manager, K8s Secrets)
- Enable HTTPS with SSL certificates
- Configure proper firewall rules
- Set up monitoring and alerting
- Regular security updates
Monitoring & Observability
Section titled “Monitoring & Observability”Health Checks
Section titled “Health Checks”# Container health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD curl -f http://localhost:4000/health || exit 1Monitoring Setup
Section titled “Monitoring Setup”- Prometheus: Metrics collection
- Grafana: Visualization and dashboards
- Jaeger: Distributed tracing
- ELK Stack: Log aggregation and analysis
Scaling Strategies
Section titled “Scaling Strategies”Horizontal Scaling
Section titled “Horizontal Scaling”- Load balancer configuration
- Auto-scaling policies
- Database read replicas
- CDN for static assets
Performance Optimization
Section titled “Performance Optimization”- Database connection pooling
- Redis caching strategies
- Image optimization
- CDN configuration
Backup & Recovery
Section titled “Backup & Recovery”Database Backups
Section titled “Database Backups”# PostgreSQL backuppg_dump -h your-db-host -U pillow pillow > backup_$(date +%Y%m%d_%H%M%S).sql
# Compressed backuppg_dump -h your-db-host -U pillow -Fc pillow > backup_$(date +%Y%m%d_%H%M%S).dump
# Restore from backuppg_restore -h your-db-host -U pillow -d pillow backup.dumpDisaster Recovery
Section titled “Disaster Recovery”- Multi-region deployments
- Data replication strategies
- Recovery time objectives (RTO)
- Recovery point objectives (RPO)
Next Steps
Section titled “Next Steps”- Configuration - Environment setup
- Monitoring - Observability and alerting
- Security - Production security practices