fix: corregir migraciones fallidas, redis doble carga y cache de assets

- Eliminar .env del tracking de git (credenciales no deben ir en repo)
- Agregar .env y .env.* al .dockerignore (no hornear credenciales en imagen)
- Quitar extension=redis.so duplicada en php.ini
- Activar cache 7d para assets estáticos en nginx
- Corregir 5 migraciones: eliminar INSERT INTO migrations con columna incorrecta
  y remover semicolons en comentarios -- que partian el parser SQL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-23 19:24:41 -05:00
co-authored by Claude Sonnet 4.6
parent a39e94c71b
commit 1342d305ec
11 changed files with 12 additions and 131 deletions
+4 -3
View File
@@ -30,9 +30,10 @@ Thumbs.db
.vscode/
*.sublime-*
# Variables de entorno locales
.env.local
.env.*.local
# Variables de entorno — nunca en la imagen
.env
.env.*
!.env.example
# Backups
backups/
-55
View File
@@ -1,55 +0,0 @@
# ============================================================
# WhatsApp Bot Manager — Variables de entorno
# Fuente única de verdad para desarrollo local.
# En producción (Coolify): configurar en Environment Variables de la app.
# ⚠️ Este archivo NO se sube a git (.gitignore lo excluye).
# ============================================================
# ── Base de datos ─────────────────────────────────────────────
DB_HOST=46.202.93.92
DB_PORT=3306
DB_NAME=usite_whatsapp_bot
DB_USER=usite_whatsapp_user
DB_PASS=6q!Vio0fn@PFmsLyHjH5
DB_ROOT_PASSWORD=root_password_2026
DB_CHARSET=utf8mb4
# ── Redis ─────────────────────────────────────────────────────
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
# ── WhatsApp Business API ─────────────────────────────────────
WHATSAPP_TOKEN=EAAcGjPRqunIBQjy3mZAVLX2vfMcyfUtcAXAwul5tZCQjsdxyEljIV1C4mOfTNAOIseZCMDZCy2O5AVM6wBXZC6nEfSNxkhosevtlZCRDr8uxe4zHiiZClW88mnjj2sv2t6PAh63VtUfY5DYAands4O5E9E6L6yiugZCZCBRIFjEWEtE1WXOn6GZCy8mgKpqTD2aQvNogZDZD
WHATSAPP_PHONE_NUMBER_ID=959898150536936
WHATSAPP_API_URL=https://graph.facebook.com/v22.0/
WEBHOOK_VERIFY_TOKEN=XimenaCaicedo2026*+
AUTO_APPROVE_TEMPLATES=true
# ── Aplicación ────────────────────────────────────────────────
APP_ENV=development
APP_DEBUG=true
APP_NAME=WhatsApp Bot System
APP_VERSION=2.0.0
APP_URL=https://bot.u-s.app/
TIMEZONE=America/Bogota
# ── Logs ──────────────────────────────────────────────────────
# Valores: DEBUG | INFO | WARNING | ERROR
LOG_LEVEL=DEBUG
ENABLE_LOGGING=true
LOG_FILE=logs/system.log
# ── Seguridad ─────────────────────────────────────────────────
SESSION_TIMEOUT=1800
MAX_LOGIN_ATTEMPTS=3
LOGIN_LOCKOUT_TIME=900
# ── Rate Limiting ─────────────────────────────────────────────
ENABLE_RATE_LIMIT=false
# ── PHP ───────────────────────────────────────────────────────
PHP_MEMORY_LIMIT=512M
PHP_MAX_EXECUTION_TIME=300
DISPLAY_ERRORS=1
ERROR_REPORTING=E_ALL
-50
View File
@@ -1,50 +0,0 @@
# Variables de entorno para Docker Compose
# Copia este archivo como .env y completa los valores
# ===========================================
# APLICACIÓN
# ===========================================
APP_ENV=production
APP_PORT=8080
# ===========================================
# BASE DE DATOS
# ===========================================
DB_HOST=db
DB_PORT=3306
DB_NAME=whatsapp_bot
DB_USER=whatsapp_user
DB_PASS=tu_password_seguro_aqui
DB_ROOT_PASSWORD=root_password_super_seguro
# ===========================================
# REDIS
# ===========================================
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0
# ===========================================
# WHATSAPP API
# ===========================================
WHATSAPP_TOKEN=tu_token_de_whatsapp_aqui
WHATSAPP_PHONE_NUMBER_ID=tu_phone_number_id_aqui
WEBHOOK_VERIFY_TOKEN=tu_token_verificacion_webhook
# ===========================================
# LOGGING
# ===========================================
LOG_LEVEL=INFO
ENABLE_RATE_LIMIT=true
# ===========================================
# WORKERS
# ===========================================
WORKER_REPLICAS=2
# ===========================================
# HERRAMIENTAS DE DESARROLLO (opcional)
# ===========================================
PHPMYADMIN_PORT=8081
REDIS_COMMANDER_PORT=8082
+2
View File
@@ -5,6 +5,8 @@
# Ignorar credenciales y entornos
.env
.env.*
!.env.example
CREDENCIALES_BASICO.txt
# Logs y temporales
+3 -10
View File
@@ -5,11 +5,6 @@ server {
root /var/www/html;
index index.php index.html;
# 🚫 CACHE DESACTIVADO GLOBALMENTE
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
@@ -84,12 +79,10 @@ server {
access_log off;
}
# Static assets - SIN CACHE para desarrollo
# Static assets
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
# CACHE DESACTIVADO
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0" always;
add_header Pragma "no-cache" always;
expires off;
expires 7d;
add_header Cache-Control "public, max-age=604800" always;
access_log off;
}
+1 -2
View File
@@ -56,5 +56,4 @@ realpath_cache_ttl = 600
; Output buffering
output_buffering = 4096
; Redis
extension = redis.so
; Redis extension habilitada vía docker-php-ext-enable en builder stage (conf.d/docker-php-ext-redis.ini)
-3
View File
@@ -22,6 +22,3 @@ WHERE permission = 'write' OR permission IS NULL;
-- Los que tienen permission='read' solo tienen can_view = 1 (ya es el DEFAULT, no tocar)
-- Registrar migración
INSERT IGNORE INTO migrations (migration, executed_at)
VALUES ('001_rbac_expandido', NOW());
-3
View File
@@ -38,6 +38,3 @@ INSERT IGNORE INTO role_modules (role_id, module_slug, can_view, can_create, can
SELECT r.id, 'whatsapp', 1, 1, 1, 0, 1
FROM roles r WHERE r.slug = 'operador_bot';
-- Registrar migración
INSERT IGNORE INTO migrations (migration, executed_at)
VALUES ('002_nuevos_roles', NOW());
+1 -1
View File
@@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS exam_tipo_consentimientos (
COMMENT='M:N entre tipos de examen y formularios de consentimiento';
-- ── 3. Lugares / estaciones de servicio configurables ───────
-- Recepción NO es un lugar; es el paso implícito del flujo.
-- Recepcion NO es un lugar (es el paso implicito del flujo).
-- Cada lugar tiene su propia cola y su propia pantalla TV.
CREATE TABLE IF NOT EXISTS turnero_lugares (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -1,5 +1,5 @@
-- Rol formularios_readonly: solo acceso a lab_formularios con permiso write
-- Permite crear y editar formularios; los envíos/resultados son solo lectura (UI)
-- Permite crear y editar formularios - los envios/resultados son solo lectura (UI)
UPDATE role_modules
SET permission = 'write'
WHERE role_id = (SELECT id FROM roles WHERE slug = 'formularios_readonly')
-3
View File
@@ -10,6 +10,3 @@ ALTER TABLE `roles`
COMMENT 'Ruta de inicio al hacer login. NULL = usa reglas heredadas.'
AFTER `color`;
-- Registrar migración
INSERT IGNORE INTO migrations (migration, executed_at)
VALUES ('20260416_roles_home_page', NOW());