Compare commits

...

7 Commits

Author SHA1 Message Date
b66d00c92d Retry 2309
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m19s
2025-06-26 23:09:33 -03:00
72c2f7ee31 Retry 2244
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m25s
2025-06-26 22:44:44 -03:00
1456ccd723 Retry 2239
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m40s
2025-06-26 22:39:09 -03:00
229f657685 Retry 2221
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 1m59s
2025-06-26 22:21:47 -03:00
13ab496727 Retry 2211
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 4m31s
2025-06-26 22:11:59 -03:00
5adc1e6d46 Se realiza fix y se añade depuración al deply
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 1m55s
2025-06-26 21:55:46 -03:00
1ec21741cc Retry Secret JWT Key
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 4m10s
2025-06-26 21:46:57 -03:00
3 changed files with 32 additions and 11 deletions

View File

@@ -26,7 +26,7 @@ jobs:
set -e
echo "--- INICIO DEL DESPLIEGUE OPTIMIZADO ---"
# 1. Preparar entorno
# 1. Preparar entorno (sin cambios)
TEMP_DIR=$(mktemp -d)
REPO_OWNER="dmolinari"
REPO_NAME="gestionintegralweb"
@@ -37,7 +37,7 @@ jobs:
cd "$TEMP_DIR"
git checkout "${{ gitea.sha }}"
# 2. Construcción paralela con Docker nativo (más rápido y fiable)
# 2. Construcción paralela (sin cambios)
build_image() {
local dockerfile=$1
local image_name=$2
@@ -55,18 +55,31 @@ jobs:
(build_image "Frontend/Dockerfile" "dmolinari/gestionintegralweb-frontend:latest" ".") &
wait
# 3. Despliegue con Docker Compose
cd /opt/gestion-integral
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD_SECRET }}'
# Copiamos la versión actualizada del docker-compose.yml al directorio de despliegue.
echo "Copiando el archivo docker-compose.yml actualizado..."
cp "$TEMP_DIR/docker-compose.yml" /opt/gestion-integral/docker-compose.yml
echo "Recreando servicios..."
docker compose up -d --force-recreate
# (Opcional pero recomendado) Verificamos que el archivo se copió bien
echo "--- Verificando contenido del docker-compose.yml que se usará ---"
cat /opt/gestion-integral/docker-compose.yml | head -n 5
echo "------------------------------------------------------------------"
# 4. Limpieza
# 3. Crear/Actualizar los Docker Secrets (sin cambios)
# ... (tus comandos docker secret create) ...
printf "%s" '${{ secrets.JWT_KEY }}' | docker secret create jwt_key - 2>/dev/null || (printf "%s" '${{ secrets.JWT_KEY }}' | docker secret rm jwt_key && printf "%s" '${{ secrets.JWT_KEY }}' | docker secret create jwt_key -)
printf "%s" '${{ secrets.DB_SA_PASSWORD_SECRET }}' | docker secret create db_password - 2>/dev/null || (printf "%s" '${{ secrets.DB_SA_PASSWORD_SECRET }}' | docker secret rm db_password && printf "%s" '${{ secrets.DB_SA_PASSWORD_SECRET }}' | docker secret create db_password -)
# 4. Desplegar el Stack
echo "Desplegando el stack..."
docker stack deploy \
-c /opt/gestion-integral/docker-compose.yml \
--with-registry-auth \
gestion-integral
# 5. Limpieza (sin cambios)
echo "Realizando limpieza..."
rm -rf "$TEMP_DIR"
docker image prune -af --filter "until=24h"
echo "--- DESPLIEGUE COMPLETADO CON ÉXITO ---"
echo "Tiempo total: $(($SECONDS / 60)) minutos y $(($SECONDS % 60)) segundos"
EOSSH

View File

@@ -112,9 +112,18 @@ builder.Services.AddHealthChecks()
// --- Configuración de Autenticación JWT ---
var jwtSettings = builder.Configuration.GetSection("Jwt");
// Lee la RUTA al archivo del secreto desde la variable de entorno
var jwtKeyFilePath = builder.Configuration["JWT_KEY_FILE"];
// Si la ruta existe (estamos en Docker Swarm), lee el contenido del archivo.
// Si no, vuelve a buscar la variable de entorno (para desarrollo local).
var jwtKey = !string.IsNullOrEmpty(jwtKeyFilePath) && File.Exists(jwtKeyFilePath)
? File.ReadAllText(jwtKeyFilePath).Trim()
: builder.Configuration["JWT_KEY"] ?? throw new ArgumentNullException("JWT Key not configured");
// Le decimos que busque la clave JWT en la raíz de la configuración (donde están las variables de entorno).
// Si no la encuentra, como respaldo, busca en la sección "Jwt" del appsettings.
var jwtKey = builder.Configuration["JWT_KEY"] ?? jwtSettings["Key"] ?? throw new ArgumentNullException("JWT_KEY or Jwt:Key not configured");
//var jwtKey = builder.Configuration["JWT_KEY"] ?? /*jwtSettings["Key"] ??*/ throw new ArgumentNullException("JWT_KEY or Jwt:Key not configured");
var keyBytes = Encoding.ASCII.GetBytes(jwtKey);

View File

@@ -6,7 +6,6 @@
}
},
"Jwt": {
"Key": "badb1a38d221c9e23bcf70958840ca7f5a5dc54f2047dadf7ce45b578b5bc3e2",
"Issuer": "GestionIntegralApi",
"Audience": "GestionIntegralClient",
"DurationInHours": 8