feat: Add Docker containerization for consistent deployment

- Multi-stage Dockerfile with Node.js 20 Alpine base
- Production and development docker-compose configurations
- Health check API endpoint for container monitoring
- Build and deployment scripts with versioning support
- Port 3000 configuration for nginx compatibility
- Non-root user and security hardening
- Resource limits and logging configuration
- Package.json scripts for Docker operations

This eliminates dependency conflicts and provides reproducible deployments.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-12 18:47:36 -06:00
parent 086aa9de6d
commit 2e575f894e
8 changed files with 523 additions and 1 deletions

58
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,58 @@
version: '3.8'
services:
bct-app:
image: bct-whitelabel:latest
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- HOST=0.0.0.0
- PORT=3000
# Supabase
- PUBLIC_SUPABASE_URL=${PUBLIC_SUPABASE_URL}
- PUBLIC_SUPABASE_ANON_KEY=${PUBLIC_SUPABASE_ANON_KEY}
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
# Stripe
- STRIPE_PUBLISHABLE_KEY=${STRIPE_PUBLISHABLE_KEY}
- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
- STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
# Email
- RESEND_API_KEY=${RESEND_API_KEY}
# Monitoring
- SENTRY_DSN=${SENTRY_DSN}
- SENTRY_RELEASE=${SENTRY_RELEASE:-latest}
env_file:
- .env
volumes:
- ./logs:/app/logs
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "const http=require('http');const options={hostname:'localhost',port:3000,path:'/api/health',timeout:2000};const req=http.request(options,(res)=>{process.exit(res.statusCode===200?0:1)});req.on('error',()=>{process.exit(1)});req.end();"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
networks:
- bct-network
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
reservations:
memory: 512M
cpus: '0.5'
networks:
bct-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16