fix(deploy): incorporar cryptography en requirements.txt y robustecer instalador install.sh

This commit is contained in:
2026-09-23 14:27:51 -03:00
parent 7a3468cd9f
commit a19f3911fe
3 changed files with 15 additions and 8 deletions
+13 -8
View File
@@ -117,7 +117,7 @@ export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq \
sudo curl wget git ca-certificates gnupg lsb-release \
build-essential libpq-dev \
build-essential libpq-dev libffi-dev libssl-dev pkg-config \
locales \
> /dev/null 2>&1
ok "Paquetes base instalados"
@@ -375,14 +375,18 @@ python3 -m venv "$VENV_DIR" > /dev/null 2>&1
"${VENV_DIR}/bin/pip" install --upgrade pip setuptools wheel --quiet
info "Instalando dependencias desde backend/requirements.txt..."
if "${VENV_DIR}/bin/pip" install -r "${BACKEND_DIR}/requirements.txt" --quiet 2>/dev/null; then
ok "Dependencias de Python instaladas correctamente"
else
warn "Reintentando instalación con --no-build-isolation..."
"${VENV_DIR}/bin/pip" install -r "${BACKEND_DIR}/requirements.txt" --no-build-isolation --quiet
ok "Dependencias de Python instaladas"
if ! "${VENV_DIR}/bin/pip" install -r "${BACKEND_DIR}/requirements.txt" --quiet; then
warn "Reintentando instalación con aislamiento deshabilitado..."
"${VENV_DIR}/bin/pip" install -r "${BACKEND_DIR}/requirements.txt" --no-build-isolation || err "Falló la instalación de dependencias de Python."
fi
# Verificación explícita de módulos críticos requeridos por modelos y esquemas
if ! "${VENV_DIR}/bin/python" -c "import flask, sqlalchemy, cryptography, pydantic; print('Módulos críticos OK')" >/dev/null 2>&1; then
warn "Asegurando librerías críticas en el venv (cryptography, pydantic)..."
"${VENV_DIR}/bin/pip" install "cryptography>=42.0.0" "pydantic>=2.0.0" --quiet
fi
ok "Dependencias de Python instaladas correctamente"
# ─── 9. Ejecución de Despliegue de Datos (Restaurar o Sincronizar) ──────────────
hdr "9. Aplicando esquema y datos en la base de datos"
@@ -420,7 +424,7 @@ done
# Sincronización idempotente con init_db.py (crea tablas o columnas faltantes sin borrar datos)
info "Sincronizando modelos y esquemas institucionales con init_db.py..."
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 PYTHONUTF8=1 PYTHONIOENCODING=utf-8 \
FLASK_APP=wsgi.py "${VENV_DIR}/bin/python" -X utf8 init_db.py
PYTHONPATH="${BACKEND_DIR}" FLASK_APP=wsgi.py "${VENV_DIR}/bin/python" -X utf8 init_db.py
ok "Esquema, usuarios y roles RBAC sincronizados con éxito"
cd "$ROOT_DIR"
@@ -482,6 +486,7 @@ Environment="LANG=en_US.UTF-8"
Environment="LC_ALL=en_US.UTF-8"
Environment="PYTHONUTF8=1"
Environment="PYTHONIOENCODING=utf-8"
Environment="PYTHONPATH=${BACKEND_DIR}"
Environment="FLASK_ENV=production"
Environment="HOME=${BACKEND_DIR}"
ExecStart=${GUNICORN_BIN} \