workspace-v1/control-plane/devtools/docker/templates/docker-compose.backend.yml
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00

101 lines
2.9 KiB
YAML

# ==============================================================================
# DOCKER COMPOSE TEMPLATE - BACKEND SERVICE
# ==============================================================================
# Template para servicios backend (Node.js, Python, etc.)
#
# USO:
# 1. Copiar a tu proyecto: cp template proyecto/docker/docker-compose.yml
# 2. Reemplazar placeholders:
# - {{SERVICE_NAME}} -> nombre del servicio (ej: gamilit-api)
# - {{PORT}} -> puerto interno (ej: 3000)
# - {{DOMAIN}} -> dominio Traefik (ej: api.gamilit.localhost)
# - {{PROJECT}} -> nombre del proyecto (ej: gamilit)
# 3. Ajustar segun necesidades
#
# REGLAS:
# - Usar expose, NO ports
# - Redes deben ser external: true
# - Incluir labels de Traefik
# - Incluir healthcheck
# ==============================================================================
version: "3.8"
# Anchors reutilizables
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
x-healthcheck: &default-healthcheck
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
services:
# ==========================================================================
# BACKEND SERVICE
# ==========================================================================
{{SERVICE_NAME}}:
build:
context: ../apps/backend
dockerfile: Dockerfile
args:
- NODE_ENV=${NODE_ENV:-development}
container_name: {{SERVICE_NAME}}
restart: unless-stopped
# IMPORTANTE: usar expose, NO ports
expose:
- "{{PORT}}"
# Variables de entorno
environment:
- NODE_ENV=${NODE_ENV:-development}
- PORT={{PORT}}
- DATABASE_URL=${DATABASE_URL}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
- JWT_SECRET=${JWT_SECRET}
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-1d}
- LOG_LEVEL=${LOG_LEVEL:-info}
# Health check
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:{{PORT}}/health"]
<<: *default-healthcheck
# Labels para Traefik
labels:
- "traefik.enable=true"
# Router
- "traefik.http.routers.{{SERVICE_NAME}}.rule=Host(`{{DOMAIN}}`)"
- "traefik.http.routers.{{SERVICE_NAME}}.entrypoints=web"
# Service
- "traefik.http.services.{{SERVICE_NAME}}.loadbalancer.server.port={{PORT}}"
# Middlewares (opcional)
# - "traefik.http.routers.{{SERVICE_NAME}}.middlewares=api-chain@file"
# Redes
networks:
- {{PROJECT}}_${ENV:-local}
- infra_shared
# Logging
logging:
<<: *default-logging
# Volumenes para desarrollo (opcional)
# volumes:
# - ../apps/backend/src:/app/src:ro
# ==============================================================================
# NETWORKS
# ==============================================================================
networks:
{{PROJECT}}_${ENV:-local}:
external: true
infra_shared:
external: true