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>
359 lines
8.5 KiB
Markdown
359 lines
8.5 KiB
Markdown
# PROMPT: DEVOPS-AGENT - FASE 3
|
|
|
|
**Fase:** 3 - Shared Infrastructure
|
|
**Agente:** DevOps-Agent
|
|
**Version:** 1.0.0
|
|
|
|
---
|
|
|
|
## PROMPT DE INICIALIZACION
|
|
|
|
```markdown
|
|
Seras DevOps-Agent trabajando en la migracion del workspace
|
|
para realizar: Crear infraestructura compartida (Fase 3)
|
|
|
|
## CONTEXTO
|
|
|
|
Las Fases 1 y 2 estan completadas:
|
|
- Control Plane creado en: /home/adrian/Documentos/workspace-v1/control-plane/
|
|
- Registries creados: ports.registry.yml, domains.registry.yml, databases.registry.yml
|
|
- Directivas SIMCO actualizadas con registry awareness
|
|
- SIMCO-DEVOPS.md creado
|
|
|
|
Tu tarea es crear la infraestructura Docker compartida que usaran todos los proyectos.
|
|
|
|
## TUS TAREAS ESPECIFICAS
|
|
|
|
### 1. Docker Networks
|
|
|
|
Crear sistema de redes aisladas por proyecto:
|
|
|
|
```yaml
|
|
ESTRUCTURA:
|
|
control-plane/devtools/docker/networks/
|
|
+-- networks.yml # Definicion de redes
|
|
+-- create-networks.sh # Script para crear redes
|
|
+-- README.md # Documentacion
|
|
|
|
REQUISITOS:
|
|
- Red compartida: infra_shared (para Traefik, monitoring)
|
|
- Redes por proyecto: {proyecto}_{ambiente}
|
|
- gamilit_local, gamilit_dev, gamilit_staging, gamilit_prod
|
|
- erp_local, erp_dev, erp_staging, erp_prod
|
|
- trading_local, trading_dev, trading_staging, trading_prod
|
|
- betting_local, betting_dev, betting_staging, betting_prod
|
|
```
|
|
|
|
### 2. Traefik Configuration
|
|
|
|
Crear configuracion de Traefik como reverse proxy:
|
|
|
|
```yaml
|
|
ESTRUCTURA:
|
|
control-plane/devtools/docker/traefik/
|
|
+-- traefik.yml # Config principal
|
|
+-- docker-compose.traefik.yml # Compose para Traefik
|
|
+-- dynamic/
|
|
+-- routers.yml # Routers dinamicos
|
|
+-- middlewares.yml # Middlewares comunes
|
|
|
|
REQUISITOS:
|
|
- Solo Traefik expone puertos 80, 443
|
|
- Dashboard en puerto 8080 (solo dev)
|
|
- Routing basado en domains.registry.yml
|
|
- Middlewares: CORS, rate-limit, security-headers
|
|
```
|
|
|
|
### 3. Docker Compose Templates
|
|
|
|
Crear templates reutilizables:
|
|
|
|
```yaml
|
|
ESTRUCTURA:
|
|
control-plane/devtools/docker/templates/
|
|
+-- docker-compose.base.yml # Logging, healthcheck defaults
|
|
+-- docker-compose.backend.yml # Template backend Node/Python
|
|
+-- docker-compose.frontend.yml # Template frontend React/Vue
|
|
+-- docker-compose.fullstack.yml # Template completo
|
|
|
|
REQUISITOS:
|
|
- Usar expose en lugar de ports
|
|
- Labels de Traefik
|
|
- Conectar a redes correctas
|
|
- Healthcheck configurado
|
|
- Placeholders: {{SERVICE_NAME}}, {{PORT}}, {{DOMAIN}}, {{PROJECT}}
|
|
```
|
|
|
|
### 4. Environment Configuration
|
|
|
|
Crear templates de variables de entorno:
|
|
|
|
```yaml
|
|
ESTRUCTURA:
|
|
control-plane/devtools/configs/env/
|
|
+-- .env.template # Template completo
|
|
+-- .env.local.template # Para desarrollo local
|
|
+-- .env.dev.template # Para ambiente dev
|
|
+-- .env.staging.template # Para staging
|
|
+-- .env.prod.template # Para produccion
|
|
|
|
REQUISITOS:
|
|
- Variables de BD (host, port, name, user, password)
|
|
- Variables de Redis
|
|
- Variables de JWT
|
|
- Variables de logging
|
|
- Placeholders claros
|
|
```
|
|
|
|
### 5. Scripts de Setup
|
|
|
|
Crear scripts de automatizacion:
|
|
|
|
```yaml
|
|
ESTRUCTURA:
|
|
control-plane/devtools/scripts/bootstrap/
|
|
+-- init-workspace.sh # Setup inicial del workspace
|
|
+-- init-project.sh # Setup de proyecto individual
|
|
|
|
REQUISITOS:
|
|
init-workspace.sh:
|
|
- Verificar Docker instalado
|
|
- Crear redes
|
|
- Levantar Traefik
|
|
- Crear directorios necesarios
|
|
|
|
init-project.sh:
|
|
- Parametros: nombre proyecto, tipo (backend/frontend/fullstack)
|
|
- Generar docker-compose desde template
|
|
- Generar .env desde template
|
|
- Verificar red existe
|
|
```
|
|
|
|
## REGISTRIES DE REFERENCIA
|
|
|
|
### ports.registry.yml
|
|
|
|
```yaml
|
|
# Extraer puertos de:
|
|
# control-plane/registries/ports.registry.yml
|
|
|
|
# Proyectos y puertos:
|
|
gamilit:
|
|
api: 3000
|
|
web: 3001
|
|
websocket: 3002
|
|
|
|
erp_suite:
|
|
api: 3010
|
|
web: 3011
|
|
|
|
erp_construccion:
|
|
api: 3012
|
|
web: 3013
|
|
```
|
|
|
|
### domains.registry.yml
|
|
|
|
```yaml
|
|
# Extraer dominios de:
|
|
# control-plane/registries/domains.registry.yml
|
|
|
|
# Dominios locales:
|
|
gamilit:
|
|
api: api.gamilit.localhost
|
|
web: gamilit.localhost
|
|
|
|
erp:
|
|
api: api.erp.localhost
|
|
web: erp.localhost
|
|
```
|
|
|
|
## RESTRICCIONES
|
|
|
|
- NO exponer puertos directamente (solo via Traefik)
|
|
- Usar redes externas (external: true)
|
|
- Scripts deben ser idempotentes
|
|
- Documentar cada archivo creado
|
|
- Incluir comentarios explicativos
|
|
|
|
## PROTOCOLO DE TRABAJO
|
|
|
|
1. Crear estructura de carpetas
|
|
2. Crear networks.yml y script
|
|
3. Crear configuracion de Traefik
|
|
4. Crear templates de docker-compose
|
|
5. Crear templates de environment
|
|
6. Crear scripts de setup
|
|
7. Probar en entorno local
|
|
8. Documentar en IMPLEMENTACION/00-EJECUCION.md
|
|
|
|
## VALIDACION
|
|
|
|
```bash
|
|
# Verificar que redes se crean
|
|
docker network ls | grep -E "(infra|gamilit|erp|trading|betting)"
|
|
|
|
# Verificar Traefik
|
|
curl http://localhost:8080/api/overview
|
|
|
|
# Verificar routing
|
|
curl http://api.gamilit.localhost/health
|
|
```
|
|
|
|
## ENTREGABLES
|
|
|
|
1. networks/
|
|
- networks.yml
|
|
- create-networks.sh
|
|
- README.md
|
|
|
|
2. traefik/
|
|
- traefik.yml
|
|
- docker-compose.traefik.yml
|
|
- dynamic/routers.yml
|
|
- dynamic/middlewares.yml
|
|
|
|
3. templates/
|
|
- docker-compose.base.yml
|
|
- docker-compose.backend.yml
|
|
- docker-compose.frontend.yml
|
|
- docker-compose.fullstack.yml
|
|
|
|
4. configs/env/
|
|
- .env.template
|
|
- .env.local.template
|
|
|
|
5. scripts/bootstrap/
|
|
- init-workspace.sh
|
|
- init-project.sh
|
|
|
|
6. Documentacion actualizada
|
|
```
|
|
|
|
---
|
|
|
|
## TEMPLATE: create-networks.sh
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
# ==============================================================================
|
|
# create-networks.sh - Crea redes Docker para el workspace
|
|
# ==============================================================================
|
|
|
|
set -e
|
|
|
|
# Colores
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${YELLOW}=== Creando redes Docker ===${NC}"
|
|
|
|
# Red de infraestructura
|
|
echo "Creando red: infra_shared"
|
|
docker network create infra_shared 2>/dev/null || echo " (ya existe)"
|
|
|
|
# Proyectos y ambientes
|
|
PROJECTS=("gamilit" "erp" "trading" "betting")
|
|
ENVIRONMENTS=("local" "dev" "staging" "prod")
|
|
|
|
for project in "${PROJECTS[@]}"; do
|
|
for env in "${ENVIRONMENTS[@]}"; do
|
|
network_name="${project}_${env}"
|
|
echo "Creando red: $network_name"
|
|
docker network create "$network_name" 2>/dev/null || echo " (ya existe)"
|
|
done
|
|
done
|
|
|
|
echo -e "${GREEN}=== Redes creadas exitosamente ===${NC}"
|
|
|
|
# Listar redes creadas
|
|
echo ""
|
|
echo "Redes disponibles:"
|
|
docker network ls --filter "driver=bridge" --format "{{.Name}}" | grep -E "(infra|gamilit|erp|trading|betting)" || true
|
|
```
|
|
|
|
---
|
|
|
|
## TEMPLATE: docker-compose.backend.yml
|
|
|
|
```yaml
|
|
# ==============================================================================
|
|
# docker-compose.backend.yml - Template para servicios backend
|
|
# ==============================================================================
|
|
# Uso: Copiar y reemplazar placeholders
|
|
# {{SERVICE_NAME}} - Nombre del servicio (ej: gamilit-api)
|
|
# {{PORT}} - Puerto interno (ej: 3000)
|
|
# {{DOMAIN}} - Dominio de Traefik (ej: api.gamilit.localhost)
|
|
# {{PROJECT}} - Nombre del proyecto (ej: gamilit)
|
|
# ==============================================================================
|
|
|
|
version: "3.8"
|
|
|
|
x-logging: &default-logging
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
services:
|
|
{{SERVICE_NAME}}:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: {{SERVICE_NAME}}
|
|
restart: unless-stopped
|
|
|
|
# IMPORTANTE: usar expose, NO ports
|
|
expose:
|
|
- "{{PORT}}"
|
|
|
|
environment:
|
|
- NODE_ENV=${NODE_ENV:-development}
|
|
- PORT={{PORT}}
|
|
- DATABASE_URL=${DATABASE_URL}
|
|
- REDIS_URL=${REDIS_URL}
|
|
- JWT_SECRET=${JWT_SECRET}
|
|
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:{{PORT}}/health"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
# Labels para Traefik
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.routers.{{SERVICE_NAME}}.rule=Host(`{{DOMAIN}}`)"
|
|
- "traefik.http.routers.{{SERVICE_NAME}}.entrypoints=web"
|
|
- "traefik.http.services.{{SERVICE_NAME}}.loadbalancer.server.port={{PORT}}"
|
|
|
|
networks:
|
|
- {{PROJECT}}_${ENV:-local}
|
|
- infra_shared
|
|
|
|
logging:
|
|
<<: *default-logging
|
|
|
|
networks:
|
|
{{PROJECT}}_${ENV:-local}:
|
|
external: true
|
|
infra_shared:
|
|
external: true
|
|
```
|
|
|
|
---
|
|
|
|
## NOTAS PARA EL AGENTE
|
|
|
|
1. **Principio fundamental:** Solo Traefik expone puertos publicos
|
|
2. **Redes:** Cada proyecto tiene su red aislada por ambiente
|
|
3. **Templates:** Deben ser copiables y usables con minima modificacion
|
|
4. **Scripts:** Idempotentes - pueden ejecutarse multiples veces
|
|
5. **Documentacion:** Cada archivo debe tener header explicativo
|
|
|
|
---
|
|
|
|
**Documento generado por:** Architecture-Analyst
|