Docs: DSPLIEGUE.md + fix deploy script
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# deploy_ksaldis.sh — Deploy automático del libro de estudio
|
||||||
|
# Llamado por el webhook de Gitea al hacer push
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REPO_DIR="/var/www/ksaldis-dt/.repo"
|
||||||
|
WEB_DIR="/var/www/ksaldis-dt"
|
||||||
|
REPO_URL="http://10.0.10.205:3000/rmonla/rm-KSALDIS-DT.git"
|
||||||
|
LOG="$WEB_DIR/deploy.log"
|
||||||
|
|
||||||
|
# Configurar git safe.directory (necesario cuando el script corre como www-data)
|
||||||
|
export GIT_CONFIG_GLOBAL=/dev/null
|
||||||
|
git config --global --add safe.directory "$REPO_DIR" 2>/dev/null || true
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo "$(date '+%Y-%m-%d %H:%M:%S') | $1" >> "$LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
log "====== Deploy iniciado ======"
|
||||||
|
|
||||||
|
# Clonar o actualizar repo
|
||||||
|
if [ -d "$REPO_DIR/.git" ]; then
|
||||||
|
cd "$REPO_DIR"
|
||||||
|
git fetch origin 2>&1
|
||||||
|
git reset --hard origin/main 2>&1
|
||||||
|
log "git pull OK"
|
||||||
|
else
|
||||||
|
rm -rf "$REPO_DIR"
|
||||||
|
git clone "$REPO_URL" "$REPO_DIR" 2>&1
|
||||||
|
log "git clone OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copiar LIBRO_DE_ESTUDIO.html como index.html
|
||||||
|
SRC="$REPO_DIR/descargar-curso/descargas/LIBRO_DE_ESTUDIO.html"
|
||||||
|
if [ -f "$SRC" ]; then
|
||||||
|
cp "$SRC" "$WEB_DIR/index.html"
|
||||||
|
log "index.html actualizado ($(wc -c < "$WEB_DIR/index.html") bytes)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copiar secciones (sin videos_offline)
|
||||||
|
SECCIONES_SRC="$REPO_DIR/descargar-curso/descargas/secciones"
|
||||||
|
if [ -d "$SECCIONES_SRC" ]; then
|
||||||
|
rsync -a --delete "$SECCIONES_SRC/" "$WEB_DIR/secciones/"
|
||||||
|
log "secciones/ actualizadas"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copiar otros assets
|
||||||
|
for asset in campus imagenes screenshots subpaginas; do
|
||||||
|
ASSET_SRC="$REPO_DIR/descargar-curso/descargas/$asset"
|
||||||
|
if [ -d "$ASSET_SRC" ]; then
|
||||||
|
rsync -a "$ASSET_SRC/" "$WEB_DIR/$asset/"
|
||||||
|
log "$asset/ actualizado"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log "====== Deploy completado ======"
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
|||||||
|
# DSPLIEGUE — Flujo de Auto-Despliegue
|
||||||
|
|
||||||
|
## Flujo
|
||||||
|
|
||||||
|
```
|
||||||
|
srv-ns8 (tu máquina local)
|
||||||
|
│ git add + commit + push
|
||||||
|
▼
|
||||||
|
srvv-gitea (10.0.10.205:3000)
|
||||||
|
│ Gitea Webhook (POST /ksaldis-dt/deploy.php)
|
||||||
|
▼
|
||||||
|
srvv-nginx-rm (10.0.10.117)
|
||||||
|
│ deploy.php → deploy_ksaldis.sh
|
||||||
|
│ git pull desde srvv-gitea
|
||||||
|
▼
|
||||||
|
/var/www/ksaldis-dt/ actualizado
|
||||||
|
```
|
||||||
|
|
||||||
|
## Archivos involucrados
|
||||||
|
|
||||||
|
| Archivo | Ruta en hosting | Función |
|
||||||
|
|---|---|---|
|
||||||
|
| `deploy.php` | `/var/www/ksaldis-dt/deploy.php` | Recibe el webhook de Gitea |
|
||||||
|
| `deploy_ksaldis.sh` | `/var/www/ksaldis-dt/deploy_ksaldis.sh` | Ejecuta git pull y copia archivos |
|
||||||
|
| `deploy.log` | `/var/www/ksaldis-dt/deploy.log` | Registro de cada deploy |
|
||||||
|
|
||||||
|
## Configuración en Gitea
|
||||||
|
|
||||||
|
- **URL del webhook**: `http://10.0.10.117/ksaldis-dt/deploy.php`
|
||||||
|
- **Content type**: `application/json`
|
||||||
|
- **Eventos**: Push events
|
||||||
|
- **Secret**: `ksaldis2026deploy` (validación HMAC-SHA256 opcional)
|
||||||
|
|
||||||
|
## Qué se actualiza
|
||||||
|
|
||||||
|
Al hacer `git push`, el webhook dispara el script que:
|
||||||
|
|
||||||
|
1. `git pull` del repositorio en `/var/www/ksaldis-dt/.repo/`
|
||||||
|
2. Copia `LIBRO_DE_ESTUDIO.html` como `index.html`
|
||||||
|
3. Sincroniza `secciones/` (PDFs, contenido)
|
||||||
|
4. Sincroniza `campus/`, `imagenes/`, `screenshots/`, `subpaginas/`
|
||||||
|
|
||||||
|
**Los videos NO se actualizan por git** (pesan ~18GB). Se copiaron manualmente a `/var/www/ksaldis-dt/videos_offline/`.
|
||||||
|
|
||||||
|
## Acceso al sitio
|
||||||
|
|
||||||
|
| URL | Descripción |
|
||||||
|
|---|---|
|
||||||
|
| `http://10.0.10.117/ksaldis-dt/` | Libro de estudio (red local) |
|
||||||
|
| `http://rmonla.duckdns.org/ksaldis-dt/` | Libro de estudio (público) |
|
||||||
|
| `http://10.0.10.205:3000/rmonla/rm-KSALDIS-DT` | Repositorio en Gitea |
|
||||||
|
|
||||||
|
## Conexiones SSH
|
||||||
|
|
||||||
|
| Origen | Destino | Usuario | Clave |
|
||||||
|
|---|---|---|---|
|
||||||
|
| srv-ns8 → srvv-gitea | `10.0.10.205` | `rmonla` | `lhsurnm$77UTN` |
|
||||||
|
| srvv-gitea → srvv-nginx-rm | `10.0.10.117` | `rmonla` | SSH key (sin pass) |
|
||||||
Reference in New Issue
Block a user