Marketplace móvil para negocios locales mexicanos. Estructura inicial: - apps/backend (NestJS API) - apps/frontend (React Web) - apps/mobile (Expo/React Native) - apps/mcp-server (Claude MCP Server) - apps/whatsapp-service (WhatsApp Business API) - database/ (PostgreSQL DDL) - docs/ (Documentación) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
206 lines
6.7 KiB
YAML
206 lines
6.7 KiB
YAML
# =============================================================================
|
|
# MiChangarrito - Docker Compose
|
|
# =============================================================================
|
|
# Version: 1.0.0
|
|
# Fecha: 2026-01-07
|
|
# Autor: @PERFIL_DEVOPS
|
|
# =============================================================================
|
|
# USO:
|
|
# docker-compose up -d # Iniciar todos los servicios
|
|
# docker-compose up -d --build # Reconstruir e iniciar
|
|
# docker-compose logs -f backend # Ver logs de un servicio
|
|
# docker-compose down # Detener todos los servicios
|
|
# docker-compose down -v # Detener y eliminar volúmenes
|
|
# =============================================================================
|
|
|
|
services:
|
|
# ===========================================================================
|
|
# DATABASE - PostgreSQL 15
|
|
# ===========================================================================
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: michangarrito-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: ${DB_USERNAME:-michangarrito_dev}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD:-MCh_dev_2025_secure}
|
|
POSTGRES_DB: ${DB_DATABASE:-michangarrito_dev}
|
|
PGDATA: /var/lib/postgresql/data/pgdata
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./database/schemas:/docker-entrypoint-initdb.d/schemas:ro
|
|
- ./database/seeds:/docker-entrypoint-initdb.d/seeds:ro
|
|
- ./database/init:/docker-entrypoint-initdb.d:ro
|
|
ports:
|
|
- "${DB_PORT:-5432}:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-michangarrito_dev} -d ${DB_DATABASE:-michangarrito_dev}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- michangarrito-network
|
|
|
|
# ===========================================================================
|
|
# CACHE - Redis 7
|
|
# ===========================================================================
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: michangarrito-redis
|
|
restart: unless-stopped
|
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
|
volumes:
|
|
- redis_data:/data
|
|
ports:
|
|
- "${REDIS_PORT:-6379}:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- michangarrito-network
|
|
|
|
# ===========================================================================
|
|
# BACKEND - NestJS API
|
|
# ===========================================================================
|
|
backend:
|
|
build:
|
|
context: ./apps/backend
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: michangarrito-backend
|
|
restart: unless-stopped
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 3141
|
|
API_PREFIX: api/v1
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_USERNAME: ${DB_USERNAME:-michangarrito_dev}
|
|
DB_PASSWORD: ${DB_PASSWORD:-MCh_dev_2025_secure}
|
|
DB_DATABASE: ${DB_DATABASE:-michangarrito_dev}
|
|
DB_SCHEMA: public
|
|
JWT_SECRET: ${JWT_SECRET}
|
|
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-7d}
|
|
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:3140}
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
|
|
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET}
|
|
OPENAI_API_KEY: ${OPENAI_API_KEY}
|
|
LLM_MODEL: ${LLM_MODEL:-gpt-4o-mini}
|
|
ports:
|
|
- "${BACKEND_PORT:-3141}:3141"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3141/api/v1/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
networks:
|
|
- michangarrito-network
|
|
|
|
# ===========================================================================
|
|
# FRONTEND - React + Vite (nginx)
|
|
# ===========================================================================
|
|
frontend:
|
|
build:
|
|
context: ./apps/frontend
|
|
dockerfile: Dockerfile
|
|
args:
|
|
VITE_API_URL: ${VITE_API_URL:-http://localhost:3141/api/v1}
|
|
container_name: michangarrito-frontend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${FRONTEND_PORT:-3140}:80"
|
|
depends_on:
|
|
- backend
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- michangarrito-network
|
|
|
|
# ===========================================================================
|
|
# WHATSAPP SERVICE - Meta Business API
|
|
# ===========================================================================
|
|
whatsapp-service:
|
|
build:
|
|
context: ./apps/whatsapp-service
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: michangarrito-whatsapp
|
|
restart: unless-stopped
|
|
environment:
|
|
NODE_ENV: production
|
|
PORT: 3143
|
|
WHATSAPP_TOKEN: ${WHATSAPP_TOKEN}
|
|
WHATSAPP_PHONE_NUMBER_ID: ${WHATSAPP_PHONE_NUMBER_ID}
|
|
WHATSAPP_BUSINESS_ACCOUNT_ID: ${WHATSAPP_BUSINESS_ACCOUNT_ID}
|
|
WHATSAPP_VERIFY_TOKEN: ${WHATSAPP_VERIFY_TOKEN}
|
|
BACKEND_URL: http://backend:3141/api/v1
|
|
ports:
|
|
- "${WHATSAPP_PORT:-3143}:3143"
|
|
depends_on:
|
|
- backend
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3143/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
networks:
|
|
- michangarrito-network
|
|
|
|
# ===========================================================================
|
|
# NGINX REVERSE PROXY (Opcional para producción)
|
|
# ===========================================================================
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: michangarrito-nginx
|
|
restart: unless-stopped
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./deploy/nginx/conf.d:/etc/nginx/conf.d:ro
|
|
- ./deploy/ssl:/etc/nginx/ssl:ro
|
|
- nginx_logs:/var/log/nginx
|
|
depends_on:
|
|
- frontend
|
|
- backend
|
|
- whatsapp-service
|
|
networks:
|
|
- michangarrito-network
|
|
profiles:
|
|
- production
|
|
|
|
# =============================================================================
|
|
# VOLUMES
|
|
# =============================================================================
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|
|
redis_data:
|
|
driver: local
|
|
nginx_logs:
|
|
driver: local
|
|
|
|
# =============================================================================
|
|
# NETWORKS
|
|
# =============================================================================
|
|
networks:
|
|
michangarrito-network:
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: 172.28.0.0/16
|