workspace/projects/erp-suite/scripts/deploy/README.md
rckrdmrd 513a86ceee
Some checks are pending
CI Pipeline / changes (push) Waiting to run
CI Pipeline / core (push) Blocked by required conditions
CI Pipeline / trading-backend (push) Blocked by required conditions
CI Pipeline / trading-data-service (push) Blocked by required conditions
CI Pipeline / trading-frontend (push) Blocked by required conditions
CI Pipeline / erp-core (push) Blocked by required conditions
CI Pipeline / erp-mecanicas (push) Blocked by required conditions
CI Pipeline / gamilit-backend (push) Blocked by required conditions
CI Pipeline / gamilit-frontend (push) Blocked by required conditions
Major update: orchestration system, catalog references, and multi-project enhancements
Core:
- Add catalog reference implementations (auth, payments, notifications, websocket, etc.)
- New agent profiles: Database Auditor, Integration Validator, LLM Agent, Policy Auditor, Trading Strategist
- Update SIMCO directives and add escalation/git guidelines
- Add deployment inventory and audit execution reports

Projects:
- erp-suite: DevOps configs, Dockerfiles, shared libs, vertical enhancements
- gamilit: Test structure, admin controllers, service refactoring, husky/commitlint
- trading-platform: MT4 gateway, auth controllers, admin frontend, deployment scripts
- platform_marketing_content: Full DevOps setup, tests, Docker configs
- betting-analytics/inmobiliaria-analytics: Initial app structure

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 22:53:55 -06:00

194 lines
5.2 KiB
Markdown

# Deploy Scripts - ERP Suite
## Arquitectura de Deploy
```
DESARROLLO (Workspace unificado) DEPLOY (Repos independientes)
================================ ==============================
/home/isem/workspace/ /home/isem/deploy-repos/
└── projects/erp-suite/ ├── erp-construccion-backend/
└── apps/verticales/ │ ├── .git/
└── construccion/ │ ├── Dockerfile
├── backend/ ───────────────>│ ├── package.json
├── frontend/ │ └── src/
│ ├── web/ ───────────────>├── erp-construccion-frontend-web/
│ └── mobile/ ─────────────>├── erp-construccion-frontend-mobile/
└── database/ ───────────────>└── erp-construccion-database/
```
## Scripts Disponibles
### sync-to-deploy-repos.sh
Sincroniza componentes del workspace a repositorios de deploy independientes.
```bash
# Uso
./sync-to-deploy-repos.sh [vertical] [componente]
# Ejemplos
./sync-to-deploy-repos.sh construccion backend # Solo backend
./sync-to-deploy-repos.sh construccion all # Toda la vertical
./sync-to-deploy-repos.sh all all # Todo el proyecto
```
## Flujo de Trabajo
### 1. Desarrollo (Workspace)
```bash
# Trabajar en el workspace unificado
cd /home/isem/workspace/projects/erp-suite/apps/verticales/construccion/backend
npm run dev
# Hacer commits al workspace
cd /home/isem/workspace
git add .
git commit -m "feat: nueva funcionalidad"
git push origin main
```
### 2. Sincronización a Deploy Repos
```bash
# Cuando esté listo para deploy
cd /home/isem/workspace/projects/erp-suite/scripts/deploy
./sync-to-deploy-repos.sh construccion backend
```
### 3. Push a Repos de Deploy
```bash
# Configurar remoto (primera vez)
cd /home/isem/deploy-repos/erp-construccion-backend
git remote add origin git@github.com:isem-digital/erp-construccion-backend.git
# Push para trigger de Jenkins
git add .
git commit -m "deploy: sync from workspace"
git push origin main
```
### 4. Jenkins Pipeline (Automático)
Jenkins detecta el push y ejecuta:
```groovy
pipeline {
agent any
environment {
DOCKER_IMAGE = "erp-construccion-backend"
DOCKER_TAG = "${BUILD_NUMBER}"
}
stages {
stage('Install') {
steps {
sh 'npm ci'
}
}
stage('Lint') {
steps {
sh 'npm run lint'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Docker Build') {
steps {
sh "docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} ."
}
}
stage('Docker Push') {
steps {
sh "docker push registry.isem.digital/${DOCKER_IMAGE}:${DOCKER_TAG}"
}
}
stage('Deploy') {
steps {
sh "kubectl set image deployment/${DOCKER_IMAGE} ${DOCKER_IMAGE}=registry.isem.digital/${DOCKER_IMAGE}:${DOCKER_TAG}"
}
}
}
}
```
## Configuración de Repositorios Remotos
### GitHub/GitLab
Para cada componente, crear un repositorio:
| Componente | Repositorio |
|------------|-------------|
| Backend | `erp-construccion-backend` |
| Frontend Web | `erp-construccion-frontend-web` |
| Frontend Mobile | `erp-construccion-frontend-mobile` |
| Database | `erp-construccion-database` |
### Configurar SSH Keys
```bash
# Generar clave SSH para deploy
ssh-keygen -t ed25519 -C "deploy@isem.digital" -f ~/.ssh/id_ed25519_deploy
# Agregar al agente SSH
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_deploy
# Copiar clave pública a GitHub/GitLab
cat ~/.ssh/id_ed25519_deploy.pub
```
## Estructura de Cada Repo de Deploy
Cada repositorio de deploy contiene:
```
erp-{vertical}-{component}/
├── .git/ # Git independiente
├── .gitignore # Generado automáticamente
├── Dockerfile # Para containerización
├── package.json # Dependencias
├── package-lock.json # Lock file
├── tsconfig.json # Config TypeScript
├── src/ # Código fuente
└── scripts/ # Scripts de utilidad
```
## Exclusiones
El script de sincronización excluye automáticamente:
- `node_modules/` - Dependencias (se instalan en CI)
- `dist/` - Build output (se genera en CI)
- `.env` - Variables de entorno locales
- `coverage/` - Reportes de cobertura
- Logs y archivos temporales
## Notas Importantes
1. **No editar los repos de deploy directamente** - Siempre trabajar en el workspace
2. **Sincronizar antes de cada deploy** - Asegura que el código está actualizado
3. **Commits separados** - El workspace y los repos de deploy tienen historiales independientes
4. **Variables de entorno** - Cada ambiente tiene su propio `.env` (no sincronizado)
---
*Última actualización: 2025-12-12*