Reversión total de JWT Key
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m6s

This commit is contained in:
2025-06-25 22:57:24 -03:00
parent c6aec21e70
commit 03cda5cdbe
2 changed files with 42 additions and 21 deletions

View File

@@ -22,51 +22,71 @@ jobs:
ssh-keyscan -H ${{ secrets.PROD_SERVER_HOST }} >> ~/.ssh/known_hosts
# Ejecuta en el host remoto
ssh ${{ secrets.PROD_SERVER_USER }}@${{ secrets.PROD_SERVER_HOST }} << EOSSH
ssh ${{ secrets.PROD_SERVER_USER }}@${{ secrets.PROD_SERVER_HOST }} << 'EOSSH'
set -e
echo "--- INICIO DEL DESPLIEGUE OPTIMIZADO ---"
TEMP_DIR=\$(mktemp -d)
# 1. Preparar entorno
TEMP_DIR=$(mktemp -d)
REPO_OWNER="dmolinari"
REPO_NAME="gestionintegralweb"
GITEA_REPO_PATH="/var/lib/docker/volumes/gitea-stack_gitea-data/_data/git/repositories/\${REPO_OWNER}/\${REPO_NAME}.git"
GITEA_REPO_PATH="/var/lib/docker/volumes/gitea-stack_gitea-data/_data/git/repositories/${REPO_OWNER}/${REPO_NAME}.git"
echo "Clonando repositorio desde: $GITEA_REPO_PATH ..."
git clone "$GITEA_REPO_PATH" "$TEMP_DIR"
cd "$TEMP_DIR"
git checkout "${{ gitea.sha }}"
# 2. Construcción paralela con Docker nativo (más rápido y fiable)
build_image() {
local dockerfile=$1
local image_name=$2
local context=$3
# 2. Directorios de caché
KANIKO_CACHE_BACKEND="/kaniko_cache/backend"
KANIKO_CACHE_FRONTEND="/kaniko_cache/frontend"
mkdir -p "$KANIKO_CACHE_BACKEND" "$KANIKO_CACHE_FRONTEND"
chmod 777 "$KANIKO_CACHE_BACKEND" "$KANIKO_CACHE_FRONTEND"
echo "Construyendo $image_name..."
docker build \
-t "$image_name" \
-f "$dockerfile" \
"$context"
# 3. Construcción paralela con Kaniko (con cache-repo local)
build_image() {
local context=$1
local dockerfile=$2
local cache_dir=$3
local image_name=$4
local tar_path=$5
docker run --rm \
-v "$TEMP_DIR":/workspace \
-v "$cache_dir":/cache \
gcr.io/kaniko-project/executor:v1.9.0 \
--context="/workspace/$context" \
--dockerfile="/workspace/$dockerfile" \
--cache=true \
--cache-dir=/cache \
--cache-repo=localhost:5000/cache \
--no-push \
--destination="$image_name" \
--tarPath="/workspace/$tar_path"
}
echo "Construyendo imágenes en paralelo..."
(build_image "Backend/GestionIntegral.Api/Dockerfile" "dmolinari/gestionintegralweb-backend:latest" ".") &
(build_image "Frontend/Dockerfile" "dmolinari/gestionintegralweb-frontend:latest" ".") &
(build_image "." "Backend/GestionIntegral.Api/Dockerfile" "$KANIKO_CACHE_BACKEND" "gestionintegralweb-backend:latest" "backend.tar") &
(build_image "." "Frontend/Dockerfile" "$KANIKO_CACHE_FRONTEND" "gestionintegralweb-frontend:latest" "frontend.tar") &
wait
# 3. Despliegue con Docker Compose
# 4. Cargar imágenes y etiquetar
echo "Cargando y etiquetando imágenes..."
docker load -i "$TEMP_DIR/backend.tar"
docker load -i "$TEMP_DIR/frontend.tar"
# Etiquetar para docker-compose
docker tag gestionintegralweb-backend:latest dmolinari/gestionintegralweb-backend:latest
docker tag gestionintegralweb-frontend:latest dmolinari/gestionintegralweb-frontend:latest
# 5. Despliegue con Docker Compose
cd /opt/gestion-integral
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD_SECRET }}'
echo "Creando archivo de entorno .env con echo..."
# Las comillas dobles permiten la expansión del secreto por Gitea,
# mientras que el > redirige la salida al archivo, sobrescribiéndolo.
echo "JWT_KEY=${{ secrets.JWT_KEY_SECRET }}" > .env
echo "Recreando servicios..."
docker compose up -d --force-recreate
# 4. Limpieza
# 6. Limpieza
echo "Realizando limpieza..."
rm -rf "$TEMP_DIR"
docker image prune -af --filter "until=24h"

View File

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