Retry Usando Docker Build Nativo
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 11m48s

This commit is contained in:
2025-06-20 12:02:10 -03:00
parent 3a0f0a4bf8
commit 1373bcf9ca

View File

@@ -37,56 +37,32 @@ jobs:
cd "$TEMP_DIR"
git checkout "${{ gitea.sha }}"
# 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)
# 2. Construcción paralela con Docker nativo (más rápido y fiable)
build_image() {
local context=$1
local dockerfile=$2
local cache_dir=$3
local image_name=$4
local tar_path=$5
local dockerfile=$1
local image_name=$2
local context=$3
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 $image_name..."
docker build \
-t "$image_name" \
-f "$dockerfile" \
"$context"
}
echo "Construyendo imágenes en paralelo..."
(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") &
(build_image "Backend/GestionIntegral.Api/Dockerfile" "dmolinari/gestionintegralweb-backend:latest" ".") &
(build_image "Frontend/Dockerfile" "dmolinari/gestionintegralweb-frontend:latest" ".") &
wait
# 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
# 3. Despliegue con Docker Compose
cd /opt/gestion-integral
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD_SECRET }}'
echo "Recreando servicios..."
docker compose up -d --force-recreate
# 6. Limpieza
# 4. Limpieza
echo "Realizando limpieza..."
rm -rf "$TEMP_DIR"
docker image prune -af --filter "until=24h"