Skip to content

Deployment

Learn how to deploy Pillow to production environments with Docker, Kubernetes, and cloud platforms.

Pillow supports multiple deployment strategies:

  • Docker Compose for simple deployments
  • Kubernetes for scalable production deployments
  • Cloud platforms (AWS, GCP, Azure)
  • Traditional server deployments
docker-compose.prod.yml
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:
Terminal window
# Set environment variables
export POSTGRES_DB=pillow
export POSTGRES_USER=pillow
export POSTGRES_PASSWORD=secure_password
# Deploy
docker compose -f docker-compose.prod.yml up -d
k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: pillow-mill
spec:
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: v1
kind: Service
metadata:
name: pillow-mill-service
spec:
selector:
app: pillow-mill
ports:
- protocol: TCP
port: 80
targetPort: 4000
type: LoadBalancer

Deploy using AWS ECS or EKS:

Terminal window
# Using AWS CLI and ECS
aws ecs create-cluster --cluster-name pillow
aws ecs create-service --cluster pillow --service-name pillow-mill

Deploy using Cloud Run or GKE:

Terminal window
# Using gcloud CLI
gcloud run deploy pillow-mill --image gcr.io/PROJECT_ID/pillow-mill

Deploy using Container Instances or AKS:

Terminal window
# Using Azure CLI
az container create --resource-group pillow-rg --name pillow-mill --image pillow/mill:latest
mill/config/.env.production
NODE_ENV=production
MILL_DATABASE_POSTGRES_HOST=your-db-host
MILL_DATABASE_POSTGRES_PORT=5432
MILL_DATABASE_POSTGRES_USER=your_user
MILL_DATABASE_POSTGRES_PASSWORD=your_secure_password
MILL_DATABASE_POSTGRES_DATABASE=pillow
MILL_DATABASE_POSTGRES_SSL_MODE=require
MILL_REDIS_HOST=your-redis-host
MILL_REDIS_PORT=6379
MILL_AUTH_JWT_SECRET=your-super-secure-secret
MILL_SERVER_PORT=4000
MILL_LOGGING_LEVEL=info
  • 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
Terminal window
# Container health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:4000/health || exit 1
  • Prometheus: Metrics collection
  • Grafana: Visualization and dashboards
  • Jaeger: Distributed tracing
  • ELK Stack: Log aggregation and analysis
  • Load balancer configuration
  • Auto-scaling policies
  • Database read replicas
  • CDN for static assets
  • Database connection pooling
  • Redis caching strategies
  • Image optimization
  • CDN configuration
Terminal window
# PostgreSQL backup
pg_dump -h your-db-host -U pillow pillow > backup_$(date +%Y%m%d_%H%M%S).sql
# Compressed backup
pg_dump -h your-db-host -U pillow -Fc pillow > backup_$(date +%Y%m%d_%H%M%S).dump
# Restore from backup
pg_restore -h your-db-host -U pillow -d pillow backup.dump
  • Multi-region deployments
  • Data replication strategies
  • Recovery time objectives (RTO)
  • Recovery point objectives (RPO)