Reversión total de JWT Key
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m6s
Some checks failed
Optimized Build and Deploy / remote-build-and-deploy (push) Failing after 1m6s
This commit is contained in:
@@ -22,51 +22,71 @@ jobs:
|
|||||||
ssh-keyscan -H ${{ secrets.PROD_SERVER_HOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan -H ${{ secrets.PROD_SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
# Ejecuta en el host remoto
|
# 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
|
set -e
|
||||||
echo "--- INICIO DEL DESPLIEGUE OPTIMIZADO ---"
|
echo "--- INICIO DEL DESPLIEGUE OPTIMIZADO ---"
|
||||||
|
|
||||||
TEMP_DIR=\$(mktemp -d)
|
# 1. Preparar entorno
|
||||||
|
TEMP_DIR=$(mktemp -d)
|
||||||
REPO_OWNER="dmolinari"
|
REPO_OWNER="dmolinari"
|
||||||
REPO_NAME="gestionintegralweb"
|
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 ..."
|
echo "Clonando repositorio desde: $GITEA_REPO_PATH ..."
|
||||||
git clone "$GITEA_REPO_PATH" "$TEMP_DIR"
|
git clone "$GITEA_REPO_PATH" "$TEMP_DIR"
|
||||||
cd "$TEMP_DIR"
|
cd "$TEMP_DIR"
|
||||||
git checkout "${{ gitea.sha }}"
|
git checkout "${{ gitea.sha }}"
|
||||||
|
|
||||||
# 2. Construcción paralela con Docker nativo (más rápido y fiable)
|
# 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"
|
||||||
|
|
||||||
|
# 3. Construcción paralela con Kaniko (con cache-repo local)
|
||||||
build_image() {
|
build_image() {
|
||||||
local dockerfile=$1
|
local context=$1
|
||||||
local image_name=$2
|
local dockerfile=$2
|
||||||
local context=$3
|
local cache_dir=$3
|
||||||
|
local image_name=$4
|
||||||
|
local tar_path=$5
|
||||||
|
|
||||||
echo "Construyendo $image_name..."
|
docker run --rm \
|
||||||
docker build \
|
-v "$TEMP_DIR":/workspace \
|
||||||
-t "$image_name" \
|
-v "$cache_dir":/cache \
|
||||||
-f "$dockerfile" \
|
gcr.io/kaniko-project/executor:v1.9.0 \
|
||||||
"$context"
|
--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..."
|
echo "Construyendo imágenes en paralelo..."
|
||||||
(build_image "Backend/GestionIntegral.Api/Dockerfile" "dmolinari/gestionintegralweb-backend:latest" ".") &
|
(build_image "." "Backend/GestionIntegral.Api/Dockerfile" "$KANIKO_CACHE_BACKEND" "gestionintegralweb-backend:latest" "backend.tar") &
|
||||||
(build_image "Frontend/Dockerfile" "dmolinari/gestionintegralweb-frontend:latest" ".") &
|
(build_image "." "Frontend/Dockerfile" "$KANIKO_CACHE_FRONTEND" "gestionintegralweb-frontend:latest" "frontend.tar") &
|
||||||
wait
|
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
|
cd /opt/gestion-integral
|
||||||
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD_SECRET }}'
|
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..."
|
echo "Recreando servicios..."
|
||||||
docker compose up -d --force-recreate
|
docker compose up -d --force-recreate
|
||||||
|
|
||||||
# 4. Limpieza
|
# 6. Limpieza
|
||||||
echo "Realizando limpieza..."
|
echo "Realizando limpieza..."
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf "$TEMP_DIR"
|
||||||
docker image prune -af --filter "until=24h"
|
docker image prune -af --filter "until=24h"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
|
"Key": "badb1a38d221c9e23bcf70958840ca7f5a5dc54f2047dadf7ce45b578b5bc3e2",
|
||||||
"Issuer": "GestionIntegralApi",
|
"Issuer": "GestionIntegralApi",
|
||||||
"Audience": "GestionIntegralClient",
|
"Audience": "GestionIntegralClient",
|
||||||
"DurationInHours": 8
|
"DurationInHours": 8
|
||||||
|
|||||||
Reference in New Issue
Block a user