This commit is contained in:
@@ -13,38 +13,49 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# --- NUEVO PASO: PREPARAMOS UN DIRECTORIO DE SALIDA PERSISTENTE ---
|
||||
- name: Create output directory
|
||||
run: mkdir -p ${{ gitea.workspace }}/output
|
||||
|
||||
- name: Build Backend Image and Save to Output
|
||||
- name: Build Backend Image and Extract
|
||||
run: |
|
||||
docker run --rm \
|
||||
echo "Building backend image..."
|
||||
# 1. Ejecutamos Kaniko y le damos un nombre, SIN --rm
|
||||
docker run --name kaniko-backend \
|
||||
-v ${{ gitea.workspace }}:/workspace \
|
||||
-v ${{ gitea.workspace }}/output:/output \
|
||||
gcr.io/kaniko-project/executor:v1.9.0 \
|
||||
--context=/workspace \
|
||||
--dockerfile=/workspace/Backend/GestionIntegral.Api/Dockerfile \
|
||||
--no-push \
|
||||
--destination=${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-backend:latest \
|
||||
--tarPath=/output/backend.tar
|
||||
--tarPath=/kaniko/backend.tar # Guardamos en una ruta interna de Kaniko
|
||||
|
||||
- name: Build Frontend Image and Save to Output
|
||||
echo "Extracting backend image..."
|
||||
# 2. Copiamos el archivo desde el contenedor de Kaniko al workspace del job
|
||||
docker cp kaniko-backend:/kaniko/backend.tar ${{ gitea.workspace }}/backend.tar
|
||||
|
||||
echo "Cleaning up backend builder..."
|
||||
# 3. Eliminamos el contenedor de Kaniko
|
||||
docker rm kaniko-backend
|
||||
|
||||
- name: Build Frontend Image and Extract
|
||||
run: |
|
||||
docker run --rm \
|
||||
echo "Building frontend image..."
|
||||
docker run --name kaniko-frontend \
|
||||
-v ${{ gitea.workspace }}:/workspace \
|
||||
-v ${{ gitea.workspace }}/output:/output \
|
||||
gcr.io/kaniko-project/executor:v1.9.0 \
|
||||
--context=/workspace \
|
||||
--dockerfile=/workspace/Frontend/Dockerfile \
|
||||
--no-push \
|
||||
--destination=${{ gitea.actor }}/${{ toLower(gitea.repository_name) }}-frontend:latest \
|
||||
--tarPath=/output/frontend.tar
|
||||
--tarPath=/kaniko/frontend.tar
|
||||
|
||||
echo "Extracting frontend image..."
|
||||
docker cp kaniko-frontend:/kaniko/frontend.tar ${{ gitea.workspace }}/frontend.tar
|
||||
|
||||
echo "Cleaning up frontend builder..."
|
||||
docker rm kaniko-frontend
|
||||
|
||||
- name: Verify Artifacts
|
||||
run: |
|
||||
echo "--- Verifying contents of output directory ---"
|
||||
ls -l ${{ gitea.workspace }}/output
|
||||
echo "--- Verifying contents of workspace ---"
|
||||
ls -l ${{ gitea.workspace }}
|
||||
|
||||
- name: Deploy to Production via SCP and SSH
|
||||
run: |
|
||||
@@ -57,8 +68,7 @@ jobs:
|
||||
ssh-keyscan -H ${{ secrets.PROD_SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
echo "Copying image files to production server..."
|
||||
# Ahora copiamos desde el subdirectorio 'output'
|
||||
scp ${{ gitea.workspace }}/output/backend.tar ${{ gitea.workspace }}/output/frontend.tar ${{ secrets.PROD_SERVER_USER }}@${{ secrets.PROD_SERVER_HOST }}:/opt/gestion-integral/
|
||||
scp ${{ gitea.workspace }}/backend.tar ${{ gitea.workspace }}/frontend.tar ${{ secrets.PROD_SERVER_USER }}@${{ secrets.PROD_SERVER_HOST }}:/opt/gestion-integral/
|
||||
|
||||
echo "Connecting to host to load images and deploy..."
|
||||
ssh ${{ secrets.PROD_SERVER_USER }}@${{ secrets.PROD_SERVER_HOST }} << 'EOF'
|
||||
|
||||
Reference in New Issue
Block a user