Initial commit: SKEEN Derma Experts - Sistema Integral de Gestión Clínica
- Frontend React (SKEEN Brand) con Vite, TypeScript, Tailwind - Frontend Homenest (versión alternativa) - Módulos Odoo 17 custom (citas, pacientes, monedero, pagos, ventas, inventario, whatsapp) - WACRM fork (Next.js 16 + Supabase) - Hermes + Bridge + Skills (Qwen3.6 via Nan Builders) - Scripts de migración y operación - Documentación extensiva en docs/
This commit is contained in:
420
docs/instalacion.md
Normal file
420
docs/instalacion.md
Normal file
@@ -0,0 +1,420 @@
|
||||
# Guía de Instalación — SKEEN Derma Experts
|
||||
|
||||
**Versión:** 2.0
|
||||
**Fecha:** 16 de julio de 2026
|
||||
|
||||
---
|
||||
|
||||
## 1. Requisitos del Sistema
|
||||
|
||||
### Hardware Mínimo
|
||||
|
||||
- **CPU:** 4 vCPU
|
||||
- **RAM:** 16 GB (22 GB recomendado)
|
||||
- **Disco:** 80 GB SSD
|
||||
- **Red:** IP pública fija (para webhooks de Meta)
|
||||
|
||||
### Software
|
||||
|
||||
| Software | Versión | Propósito |
|
||||
|----------|---------|-----------|
|
||||
| Ubuntu | 22.04 LTS | Sistema operativo |
|
||||
| Docker | 24+ | Supabase self-hosted |
|
||||
| Docker Compose | 2.20+ | Orquestación Supabase |
|
||||
| Node.js | 20+ | WACRM, Bridge, Frontend build |
|
||||
| Python | 3.12+ | Odoo, migración |
|
||||
| PostgreSQL | 16 | Odoo DB |
|
||||
| nginx | 1.24+ | Reverse proxy, static files |
|
||||
| git | 2.40+ | Control de versiones |
|
||||
|
||||
---
|
||||
|
||||
## 2. Instalación del Sistema Base
|
||||
|
||||
```bash
|
||||
# Actualizar sistema
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Instalar dependencias base
|
||||
sudo apt install -y \
|
||||
curl wget git nginx postgresql postgresql-contrib \
|
||||
build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev \
|
||||
libjpeg-dev libpq-dev python3 python3-pip python3-venv \
|
||||
python3-dev libldap2-dev libsasl2-dev
|
||||
|
||||
# Instalar Node.js 20
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
||||
sudo apt install -y nodejs
|
||||
|
||||
# Instalar Docker
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
sudo usermod -aG docker $USER
|
||||
newgrp docker
|
||||
|
||||
# Instalar Docker Compose
|
||||
sudo apt install -y docker-compose-plugin
|
||||
|
||||
# Verificar instalaciones
|
||||
node -v # v20.x
|
||||
python3 --version # 3.12.x
|
||||
docker --version
|
||||
docker compose version
|
||||
psql --version
|
||||
nginx -v
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Configuración de PostgreSQL
|
||||
|
||||
```bash
|
||||
# Crear usuario y base de datos para Odoo
|
||||
sudo -u postgres psql << 'EOF'
|
||||
CREATE USER skeen WITH PASSWORD 'skeen_dev_2026';
|
||||
ALTER USER skeen CREATEDB;
|
||||
CREATE DATABASE skeen_odoo OWNER skeen;
|
||||
EOF
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Instalación de Supabase Self-Hosted
|
||||
|
||||
```bash
|
||||
# Clonar Supabase
|
||||
cd /root
|
||||
git clone https://github.com/supabase/supabase.git skeen-supabase
|
||||
cd skeen-supabase/docker
|
||||
|
||||
# Configurar variables de entorno
|
||||
cp .env.example .env
|
||||
# Editar .env con tus valores
|
||||
|
||||
# Levantar Supabase
|
||||
docker compose up -d
|
||||
|
||||
# Verificar contenedores
|
||||
docker compose ps
|
||||
docker compose logs -f db
|
||||
```
|
||||
|
||||
**Variables importantes en `.env`:**
|
||||
|
||||
```env
|
||||
POSTGRES_PASSWORD=your_postgres_password
|
||||
JWT_SECRET=your_jwt_secret_32_chars
|
||||
ANON_KEY=your_anon_jwt
|
||||
SERVICE_ROLE_KEY=your_service_role_jwt
|
||||
DASHBOARD_USERNAME=supabase
|
||||
DASHBOARD_PASSWORD=your_dashboard_password
|
||||
SITE_URL=http://localhost:3000
|
||||
ADDITIONAL_REDIRECT_URLS=http://localhost:3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Instalación de WACRM
|
||||
|
||||
```bash
|
||||
cd /root
|
||||
git clone https://github.com/ArnasDon/wacrm.git skeen-wacrm
|
||||
cd skeen-wacrm
|
||||
|
||||
# Instalar dependencias
|
||||
npm install
|
||||
|
||||
# Configurar entorno
|
||||
cp .env.local.example .env.local
|
||||
```
|
||||
|
||||
**Editar `.env.local`:**
|
||||
|
||||
```env
|
||||
# Supabase (self-hosted on localhost)
|
||||
NEXT_PUBLIC_SUPABASE_URL=http://localhost:8000
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
|
||||
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
|
||||
|
||||
# Encryption key for WACRM (64 hex chars)
|
||||
ENCRYPTION_KEY=your_64_hex_char_key
|
||||
|
||||
# WhatsApp / Meta (pending client data)
|
||||
WHATSAPP_PHONE_NUMBER_ID=PENDING_PHONE_ID
|
||||
WHATSAPP_BUSINESS_ACCOUNT_ID=PENDING_WABA_ID
|
||||
WHATSAPP_ACCESS_TOKEN=PENDING_TOKEN
|
||||
WHATSAPP_VERIFY_TOKEN=skeen_webhook_verify_2026
|
||||
|
||||
# Meta App Secret for webhook signature verification
|
||||
META_APP_SECRET=your_meta_app_secret
|
||||
|
||||
# Application
|
||||
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
||||
NODE_ENV=development
|
||||
```
|
||||
|
||||
**Ejecutar migraciones de base de datos:**
|
||||
|
||||
```bash
|
||||
# Ejecutar migraciones SQL en Supabase
|
||||
# Las migraciones 026_api_keys.sql y 028_webhook_endpoints.sql son REQUERIDAS
|
||||
```
|
||||
|
||||
**Build y arrancar:**
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
npm start
|
||||
# Dev: npm run dev (localhost:3000)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Instalación de Odoo 17
|
||||
|
||||
```bash
|
||||
cd /root
|
||||
git clone https://github.com/odoo/odoo.git --depth 1 --branch 17.0 skeen-odoo
|
||||
cd skeen-odoo
|
||||
|
||||
# Crear entorno virtual
|
||||
python3 -m venv /root/odoo-venv
|
||||
source /root/odoo-venv/bin/activate
|
||||
|
||||
# Instalar dependencias
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Configurar odoo.conf
|
||||
cat > odoo.conf << 'EOF'
|
||||
[options]
|
||||
addons_path = /root/skeen-odoo/addons,/root/skeen-odoo/odoo/addons
|
||||
admin_passwd = skeen_admin_2026
|
||||
db_host = localhost
|
||||
db_name = skeen_odoo
|
||||
db_password = skeen_dev_2026
|
||||
db_port = 5432
|
||||
db_user = skeen
|
||||
http_port = 8069
|
||||
proxy_mode = True
|
||||
workers = 0
|
||||
EOF
|
||||
|
||||
# Copiar módulos custom
|
||||
cp -r /root/SKEEN-Proyecto/odoo-addons/* /root/skeen-odoo/addons/
|
||||
|
||||
# Iniciar Odoo
|
||||
./odoo-bin -c odoo.conf --logfile=/tmp/odoo.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Instalación de Hermes
|
||||
|
||||
```bash
|
||||
cd /root
|
||||
git clone https://github.com/NousResearch/Hermes-Agent.git hermes-repo
|
||||
cd hermes-repo
|
||||
|
||||
# Crear entorno virtual
|
||||
python3 -m venv /root/hermes-venv
|
||||
source /root/hermes-venv/bin/activate
|
||||
|
||||
# Instalar
|
||||
pip install -e .
|
||||
|
||||
# Configurar
|
||||
hermes setup
|
||||
```
|
||||
|
||||
**Configurar variables de entorno:**
|
||||
|
||||
```bash
|
||||
export NAN_API_KEY=sk-gJ8OWbZVGeWy9ns_H00cxA
|
||||
export NAN_BASE_URL=https://api.nan.builders/v1
|
||||
```
|
||||
|
||||
**Iniciar gateway:**
|
||||
|
||||
```bash
|
||||
hermes gateway run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Instalación del Bridge SKEEN
|
||||
|
||||
```bash
|
||||
cd /root/skeen-roadmap-hermes/hermes
|
||||
npm install
|
||||
|
||||
# Configurar
|
||||
cat > .env << 'EOF'
|
||||
NAN_API_KEY=sk-gJ8OWbZVGeWy9ns_H00cxA
|
||||
NAN_BASE_URL=https://api.nan.builders/v1
|
||||
NAN_MODEL=qwen3.6
|
||||
WACRM_URL=http://localhost:3000
|
||||
WACRM_API_KEY=your_wacrm_api_key
|
||||
BRIDGE_PORT=8090
|
||||
EOF
|
||||
|
||||
# Iniciar bridge
|
||||
node webhook-bridge.js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. Instalación del Frontend React
|
||||
|
||||
```bash
|
||||
cd /root
|
||||
git clone https://git.consultoria-as.com/consultoria-as/SKEEN-Proyecto.git
|
||||
cd SKEEN-Proyecto/frontend
|
||||
|
||||
# Instalar dependencias
|
||||
npm install
|
||||
|
||||
# Desarrollo
|
||||
npm run dev
|
||||
|
||||
# Producción
|
||||
npm run build
|
||||
sudo mkdir -p /var/www/skeen-frontend
|
||||
sudo cp -r dist/* /var/www/skeen-frontend/
|
||||
```
|
||||
|
||||
**Configurar nginx:**
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name skeen.consultoria-as.com;
|
||||
root /var/www/skeen-frontend;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/odoo {
|
||||
proxy_pass http://localhost:8069;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /api/wacrm {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 10. Configuración de Automatización en WACRM
|
||||
|
||||
1. Ir a **WACRM Dashboard → Automations**.
|
||||
2. Crear automatización "Nuevo mensaje → Webhook Hermes Bridge":
|
||||
- **Trigger:** `new_message_received`
|
||||
- **Step:** `send_webhook`
|
||||
- **URL:** `http://localhost:8090/webhook/wacrm`
|
||||
- **Body:** `{"from":"{{ vars.contact_phone }}","text":"{{ message.text }}","conversation_id":"{{ vars.conversation_id }}","contact_id":"{{ vars.contact_id }}"}`
|
||||
|
||||
---
|
||||
|
||||
## 11. Creación de API Key en WACRM
|
||||
|
||||
1. Ir a **WACRM Dashboard → Settings → API Keys**.
|
||||
2. Crear nueva API key con scopes:
|
||||
- `messages:send`
|
||||
- `messages:read`
|
||||
- `contacts:read`
|
||||
- `contacts:write`
|
||||
- `conversations:read`
|
||||
- `broadcasts:send`
|
||||
- `webhooks:manage`
|
||||
3. Guardar la key en `.env` del bridge como `WACRM_API_KEY`.
|
||||
|
||||
---
|
||||
|
||||
## 12. Verificación de la Instalación
|
||||
|
||||
```bash
|
||||
# Health checks
|
||||
curl http://localhost:8069/web/health
|
||||
curl http://localhost:8090/health
|
||||
curl http://localhost:8069/skeen/frontend/v1/health
|
||||
|
||||
# Servicios corriendo
|
||||
ss -tlnp | grep -E "3000|5173|8069|8000|8090|8644|8080|9119"
|
||||
|
||||
# Logs
|
||||
tail -f /tmp/wacrm.log
|
||||
tail -f /tmp/odoo.log
|
||||
tail -f /tmp/hermes-bridge.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 13. Troubleshooting Común
|
||||
|
||||
### WACRM no conecta a Supabase
|
||||
|
||||
```bash
|
||||
# Verificar contenedores
|
||||
cd /root/skeen-supabase/docker && docker compose ps
|
||||
|
||||
# Verificar variables de entorno
|
||||
cat /root/skeen-wacrm/.env.local | grep SUPABASE
|
||||
```
|
||||
|
||||
### Odoo no inicia
|
||||
|
||||
```bash
|
||||
# Ver logs
|
||||
tail -100 /tmp/odoo.log
|
||||
|
||||
# Verificar PostgreSQL
|
||||
sudo -u postgres psql -d skeen_odoo -c "SELECT 1;"
|
||||
```
|
||||
|
||||
### Bridge no responde
|
||||
|
||||
```bash
|
||||
# Verificar puerto
|
||||
ss -tlnp | grep 8090
|
||||
|
||||
# Ver logs
|
||||
tail -100 /tmp/hermes-bridge.log
|
||||
```
|
||||
|
||||
### Frontend no carga
|
||||
|
||||
```bash
|
||||
# Verificar nginx
|
||||
sudo nginx -t
|
||||
sudo systemctl status nginx
|
||||
|
||||
# Verificar build
|
||||
ls -la /var/www/skeen-frontend/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 14. Scripts de Operación
|
||||
|
||||
| Script | Propósito |
|
||||
|--------|-----------|
|
||||
| `scripts/skeen-start-all.sh` | Inicia todo el ecosistema |
|
||||
| `scripts/skeen-stop-all.sh` | Detiene todo el ecosistema |
|
||||
| `scripts/skeen-start-odoo.sh` | Inicia solo Odoo |
|
||||
|
||||
---
|
||||
|
||||
## 15. Notas de Producción
|
||||
|
||||
1. **HTTPS:** Configurar SSL con Let's Encrypt antes de go-live.
|
||||
2. **Firewall:** Abrir solo puertos necesarios (80, 443, 22).
|
||||
3. **Backups:** Configurar backups diarios de PostgreSQL.
|
||||
4. **Monitoreo:** Instalar Uptime Kuma.
|
||||
5. **Logs:** Configurar logrotate para `/tmp/*.log`.
|
||||
6. **Variables de entorno:** Usar systemd EnvironmentFile o .env files.
|
||||
Reference in New Issue
Block a user