Compare commits

...

26 Commits

Author SHA1 Message Date
840ef44670 fix: add image names to docker-compose and update CI pipeline with login-action
All checks were successful
CI/CD Pipeline / backend-build (push) Successful in 2m3s
CI/CD Pipeline / frontend-build (push) Successful in 43s
CI/CD Pipeline / docker-build (push) Successful in 1m18s
2026-04-04 19:25:52 -03:00
42cb6e0d67 Fix: CI Version
All checks were successful
CI/CD Pipeline / backend-build (push) Successful in 2m14s
CI/CD Pipeline / frontend-build (push) Successful in 41s
CI/CD Pipeline / docker-build (push) Successful in 1m43s
2026-04-04 19:08:58 -03:00
6de2518a72 Fix: Label para Relacion Paquete Repositorio
All checks were successful
CI/CD Pipeline / backend-build (push) Successful in 2m20s
CI/CD Pipeline / frontend-build (push) Successful in 52s
CI/CD Pipeline / docker-build (push) Successful in 1m29s
2026-04-04 18:55:17 -03:00
6a4b16bb8b Retry CI Login con Usuario
All checks were successful
CI/CD Pipeline / backend-build (push) Successful in 2m10s
CI/CD Pipeline / frontend-build (push) Successful in 35s
CI/CD Pipeline / docker-build (push) Successful in 2m4s
2026-04-04 18:37:47 -03:00
f70ecaeeb5 Retry Ci Login
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m9s
CI/CD Pipeline / frontend-build (push) Successful in 40s
CI/CD Pipeline / docker-build (push) Failing after 48s
2026-04-04 18:29:00 -03:00
8459327d8b Retry ci Login
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m9s
CI/CD Pipeline / frontend-build (push) Successful in 45s
CI/CD Pipeline / docker-build (push) Failing after 16s
2026-04-04 18:24:29 -03:00
29b497468e Fix Login CI.yml
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m31s
CI/CD Pipeline / frontend-build (push) Successful in 1m17s
CI/CD Pipeline / docker-build (push) Failing after 18s
2026-04-04 18:14:57 -03:00
c33b186098 Repush 2 2026-04-03 21:03:19 -03:00
56e7b8b0a8 Repush 1 2026-04-03 21:00:15 -03:00
11638026d9 Repush 2026-04-03 20:57:38 -03:00
e3db9eb87f Fix: Login con Secret Token en CI 2026-04-03 20:55:50 -03:00
3a85201154 Fix: ci.yml con login previo a steps
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m6s
CI/CD Pipeline / frontend-build (push) Successful in 36s
CI/CD Pipeline / docker-build (push) Failing after 13s
2026-04-03 20:46:41 -03:00
865cf9b3e8 test ci.yml runner
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m18s
CI/CD Pipeline / frontend-build (push) Successful in 1m8s
CI/CD Pipeline / docker-build (push) Failing after 1m11s
2026-04-03 20:39:29 -03:00
eb5f04e5e2 docs: add README.md 2026-04-03 20:35:27 -03:00
ca15833526 chore: trigger pipeline with empty commit 2026-04-03 20:25:19 -03:00
67b56c1c9b fix: improve docker-build job with login, compose push, and correct image names 2026-04-03 20:23:13 -03:00
ed7586f950 fix: add DOCKER_API_VERSION env to job for API compatibility
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m15s
CI/CD Pipeline / frontend-build (push) Successful in 51s
CI/CD Pipeline / docker-build (push) Failing after 1m52s
2026-04-03 20:05:40 -03:00
361be0eb9e fix: use lowercase repo name and add image cleanup step
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m53s
CI/CD Pipeline / frontend-build (push) Successful in 1m20s
CI/CD Pipeline / docker-build (push) Failing after 2m0s
2026-04-03 19:42:16 -03:00
667b01c2a0 feat: push Docker images to Gitea registry after build
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m36s
CI/CD Pipeline / frontend-build (push) Successful in 54s
CI/CD Pipeline / docker-build (push) Failing after 2m3s
2026-04-03 19:34:42 -03:00
d3e77ad9a5 fix: correct paths in Backend Dockerfile for docker compose build context
All checks were successful
CI/CD Pipeline / backend-build (push) Successful in 2m15s
CI/CD Pipeline / frontend-build (push) Successful in 53s
CI/CD Pipeline / docker-build (push) Successful in 7m14s
The docker-compose.yml uses 'context: .' (root), so paths must include 'Backend/' prefix.
2026-04-03 19:15:29 -03:00
fd52352b21 fix: use docker label for build job (runner has docker-cli)
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m53s
CI/CD Pipeline / frontend-build (push) Successful in 1m19s
CI/CD Pipeline / docker-build (push) Failing after 39s
2026-04-01 21:25:44 -03:00
86a4b7cc1d fix: use docker compose v2 (plugin) in CI
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 2m58s
CI/CD Pipeline / frontend-build (push) Successful in 1m4s
CI/CD Pipeline / docker-build (push) Failing after 23s
2026-04-01 21:15:01 -03:00
5fed217818 fix: use docker build instead of docker-compose in CI
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 3m19s
CI/CD Pipeline / docker-build (push) Has been cancelled
CI/CD Pipeline / frontend-build (push) Has been cancelled
2026-04-01 21:11:18 -03:00
03c2cbf90b fix: install Docker CLI in CI step before docker-compose build
Some checks failed
CI/CD Pipeline / frontend-build (push) Has been cancelled
CI/CD Pipeline / backend-build (push) Has been cancelled
CI/CD Pipeline / docker-build (push) Has been cancelled
Each CI step runs in a separate container (node:18-bullseye).
Docker CLI must be installed within that container to use docker-compose.
2026-04-01 21:07:42 -03:00
2061ea5c0e revert: use docker-compose v1 in CI (runner now has docker-cli-compose)
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 3m14s
CI/CD Pipeline / frontend-build (push) Successful in 1m20s
CI/CD Pipeline / docker-build (push) Failing after 23s
2026-04-01 21:01:01 -03:00
8729de88a7 fix: use docker compose v2 instead of docker-compose in CI
Some checks failed
CI/CD Pipeline / backend-build (push) Successful in 3m4s
CI/CD Pipeline / frontend-build (push) Successful in 57s
CI/CD Pipeline / docker-build (push) Failing after 30s
docker-compose (v1) not available in gitea/act_runner container.
Docker Compose v2 is available as a plugin via 'docker compose'.
2026-04-01 20:31:41 -03:00
5 changed files with 248 additions and 11 deletions

View File

@@ -52,14 +52,37 @@ jobs:
run: npm run test:run run: npm run test:run
working-directory: Frontend working-directory: Frontend
# Docker build job (depends on backend and frontend builds)
docker-build: docker-build:
needs: [backend-build, frontend-build] needs: [backend-build, frontend-build]
runs-on: ubuntu-latest runs-on: docker
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
env:
DOCKER_API_VERSION: "1.41"
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: repo.eldiaservicios.com
username: dmolinari
password: ${{ secrets.TOKEN_REGISTRY }}
- name: Build Docker images - name: Build Docker images
run: docker-compose build run: docker compose build
- name: Tag versioned images
run: |
docker tag repo.eldiaservicios.com/dmolinari/pruebagentle/backend:latest repo.eldiaservicios.com/dmolinari/pruebagentle/backend:${{ github.run_number }}
docker tag repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:latest repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:${{ github.run_number }}
- name: Push to registry
run: |
docker compose push
docker push repo.eldiaservicios.com/dmolinari/pruebagentle/backend:${{ github.run_number }}
docker push repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:${{ github.run_number }}
- name: Clean up old images
run: |
docker images --format '{{.Repository}}:{{.Tag}}' | grep 'repo.eldiaservicios.com/dmolinari/pruebagentle' | tail -n +3 | xargs -r docker rmi || true

View File

@@ -4,12 +4,12 @@ EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src WORKDIR /src
COPY PruebaGentle.Core/PruebaGentle.Core.csproj PruebaGentle.Core/ COPY Backend/PruebaGentle.Core/PruebaGentle.Core.csproj Backend/PruebaGentle.Core/
COPY PruebaGentle.Infrastructure/PruebaGentle.Infrastructure.csproj PruebaGentle.Infrastructure/ COPY Backend/PruebaGentle.Infrastructure/PruebaGentle.Infrastructure.csproj Backend/PruebaGentle.Infrastructure/
COPY PruebaGentle.API/PruebaGentle.API.csproj PruebaGentle.API/ COPY Backend/PruebaGentle.API/PruebaGentle.API.csproj Backend/PruebaGentle.API/
RUN dotnet restore PruebaGentle.API/PruebaGentle.API.csproj RUN dotnet restore Backend/PruebaGentle.API/PruebaGentle.API.csproj
COPY . . COPY . .
WORKDIR /src/PruebaGentle.API WORKDIR /src/Backend/PruebaGentle.API
RUN dotnet build -c Release -o /app/build RUN dotnet build -c Release -o /app/build
FROM build AS publish FROM build AS publish

167
Bitacora-CICD-Gitea.md Normal file
View File

@@ -0,0 +1,167 @@
# 📖 Bitácora de Configuración CI/CD en Gitea
## Fase 1: Configuración del Gitea Act-Runner
**Objetivo:** Levantar el contenedor que ejecutará los pipelines de Gitea (el "runner").
* **Problema 1:** El contenedor del runner no iniciaba y arrojaba el error `accepts at most 0 arg(s), received 1`.
* **Causa:** Un espacio en blanco después de la coma en la variable de entorno `GITEA_RUNNER_LABELS` que Bash interpretaba como un argumento adicional.
* **Solución:** Eliminar el espacio y encerrar toda la declaración entre comillas dobles en el `docker-compose.yml` de Gitea:
`- "GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:18-bullseye,docker:docker://repo.eldiaservicios.com/dmolinari/act-runner:latest"`
## Fase 2: Preparación del Proyecto y Docker Compose
**Objetivo:** Que el código fuente (Backend y Frontend) se construya correctamente dentro de Docker.
* **Problema 2:** Error al construir la imagen del backend: `ERROR: "/PruebaGentle.API.csproj" not found`.
* **Causa:** El "contexto" de construcción (`context`) estaba mal referenciado; Docker buscaba el archivo en la raíz cuando en realidad estaba dentro de la carpeta `Backend/`.
* **Solución:** Se ajustó el `docker-compose.yml` del proyecto definiendo explícitamente los contextos (`context: ./Backend` y `context: ./Frontend`).
* **Problema 3:** Gitea no mostraba los paquetes en la pestaña "Paquetes" del repositorio.
* **Causa:** Las imágenes no tenían metadatos que le dijeran a Gitea a qué repositorio pertenecían.
* **Solución:** Se agregaron etiquetas OCI (`labels`) al `docker-compose.yml` del proyecto.
* **Problema 4:** Docker Compose no sabía cómo llamar a las imágenes, dando errores al intentar etiquetarlas con `docker tag backend`.
* **Solución:** Declarar el nombre exacto de la imagen en la propiedad `image:` de cada servicio.
**✅ Resultado final de `docker-compose.yml` (Proyecto):**
```yaml
services:
backend:
image: repo.eldiaservicios.com/dmolinari/pruebagentle/backend:latest
build:
context: ./Backend
dockerfile: Dockerfile
labels:
- "org.opencontainers.image.source=https://repo.eldiaservicios.com/dmolinari/PruebaGentle"
frontend:
image: repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:latest
build:
context: ./Frontend
dockerfile: Dockerfile
labels:
- "org.opencontainers.image.source=https://repo.eldiaservicios.com/dmolinari/PruebaGentle"
```
## Fase 3: Solución de Problemas en el Pipeline (Errores de Gitea Actions)
**Objetivo:** Que el Action compile, inicie sesión y suba las imágenes a Gitea Registry.
* **Problema 5:** Error `client version 1.52 is too new. Maximum supported API version is 1.41`.
* **Causa:** El Docker Engine del servidor host es más antiguo que el cliente instalado en el runner. Las variables de entorno del `Dockerfile` se borraban al iniciar el job.
* **Solución:** Forzar la compatibilidad inyectando `env: DOCKER_API_VERSION: "1.41"` directamente a nivel del Job en el archivo `ci.yml`.
* **Problema 6:** Errores de Autenticación (`unauthorized`, `cannot perform an interactive login from a non TTY device` y `Password required`).
* **Causa:** Faltaba el paso para iniciar sesión en el Registry. Al intentar pasarlo por consola, si una variable estaba vacía, Docker pedía la clave por teclado, colgando el proceso (non TTY). Además, el token por defecto de Gitea no tenía permisos de escritura para paquetes.
* **Solución:**
1. Se generó un **Token de Acceso Personal (PAT)** desde el perfil del usuario con permisos de lectura/escritura en *Packages*.
2. Se guardó este token en **Configuración del Repositorio -> Acciones -> Secretos** bajo el nombre `TOKEN_REGISTRY`.
3. Se implementó la acción oficial `docker/login-action@v3` para manejar el login de forma segura.
* **Problema 7:** Las imágenes subidas sobreescribían el historial (todo era `latest`).
* **Causa:** La etiqueta `latest` reemplaza a la anterior sin guardar historial.
* **Solución:** Implementar doble etiquetado. Subir `:latest` (para producción) y subir `:${{ github.run_number }}` (para mantener un registro de versiones atado a la ejecución del Action).
## Fase 4: El Archivo Pipeline Final (`ci.yml`)
Este es el archivo definitivo, pulido y profesional que logró integrar todo el proceso:
```yaml
name: CI/CD Pipeline
# Triggers: push to main and pull requests to main
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# Backend build job
backend-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: Restore dependencies
run: dotnet restore Backend/PruebaGentle.slnx
- name: Build backend
run: dotnet build Backend/PruebaGentle.slnx --configuration Release
# Frontend build job
frontend-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Install dependencies
run: npm ci
working-directory: Frontend
- name: Build frontend
run: npm run build
working-directory: Frontend
- name: Run tests
run: npm run test:run
working-directory: Frontend
docker-build:
needs: [backend-build, frontend-build]
runs-on: docker
if: github.ref == 'refs/heads/main'
env:
DOCKER_API_VERSION: "1.41"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: repo.eldiaservicios.com
username: dmolinari
password: ${{ secrets.TOKEN_REGISTRY }}
- name: Build Docker images
run: docker compose build
- name: Tag versioned images
run: |
docker tag repo.eldiaservicios.com/dmolinari/pruebagentle/backend:latest repo.eldiaservicios.com/dmolinari/pruebagentle/backend:${{ github.run_number }}
docker tag repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:latest repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:${{ github.run_number }}
- name: Push to registry
run: |
docker compose push
docker push repo.eldiaservicios.com/dmolinari/pruebagentle/backend:${{ github.run_number }}
docker push repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:${{ github.run_number }}
- name: Clean up old images
run: |
docker images --format '{{.Repository}}:{{.Tag}}' | grep 'repo.eldiaservicios.com/dmolinari/pruebagentle' | tail -n +3 | xargs -r docker rmi || true
```
## Fase 5: Mantenimiento y Retención del Servidor
**Objetivo:** Evitar que el disco del servidor colapse por acumular cientos de versiones de imágenes.
* **Acción tomada:** Se configuró una regla de limpieza automática desde la cuenta de **Administrador del sitio** de Gitea (`/admin/packages`).
* **Regla implementada:**
* Tipo: `Container`
* Mantener el más reciente: `5 versiones por paquete` (Esto actúa como escudo de seguridad mínimo).
* Eliminar versiones anteriores a: `X días` (Para limpiar la basura antigua periódicamente).
* **Aclaración de Interfaz:** Se aprendió que Gitea agrupa los paquetes en la vista del repositorio (hay que hacer clic para ver las versiones), mientras que en la vista de administración muestra todas las etiquetas desagrupadas.
---

41
README.md Normal file
View File

@@ -0,0 +1,41 @@
# PruebaGentle
Proyecto de prueba con backend .NET y frontend React.
## Tech Stack
- **Backend**: .NET 10 + Dapper + SQL Server
- **Frontend**: React 19 + Vite + Tailwind CSS
- **Database**: SQL Server (Docker)
- **CI/CD**: Gitea Actions
## Desarrollo Local
### Requisitos
- .NET 10 SDK
- Node.js 22+
- Docker Desktop
### Comandos
```bash
# Frontend
cd Frontend
npm install
npm run dev
# Backend
cd Backend
dotnet restore
dotnet run
# Docker (todo)
docker compose up -d
```
## Pipeline
El pipeline de CI/CD corre en Gitea Actions y construye:
1. Backend (.NET)
2. Frontend (React + Vite)
3. Imágenes Docker (push al registry de Gitea)

View File

@@ -1,5 +1,3 @@
version: '3.8'
services: services:
sqlserver: sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest image: mcr.microsoft.com/mssql/server:2022-latest
@@ -20,9 +18,13 @@ services:
start_period: 30s start_period: 30s
backend: backend:
# 1. AÑADIMOS EL NOMBRE DE LA IMAGEN AQUÍ
image: repo.eldiaservicios.com/dmolinari/pruebagentle/backend:latest
build: build:
context: . context: .
dockerfile: Backend/Dockerfile dockerfile: Backend/Dockerfile
labels:
- "org.opencontainers.image.source=https://repo.eldiaservicios.com/dmolinari/PruebaGentle"
ports: ports:
- "5000:8080" - "5000:8080"
environment: environment:
@@ -35,13 +37,17 @@ services:
condition: service_healthy condition: service_healthy
frontend: frontend:
# 2. AÑADIMOS EL NOMBRE DE LA IMAGEN AQUÍ
image: repo.eldiaservicios.com/dmolinari/pruebagentle/frontend:latest
build: build:
context: ./Frontend context: ./Frontend
dockerfile: Dockerfile dockerfile: Dockerfile
labels:
- "org.opencontainers.image.source=https://repo.eldiaservicios.com/dmolinari/PruebaGentle"
ports: ports:
- "8181:80" - "8181:80"
depends_on: depends_on:
- backend - backend
volumes: volumes:
sqlserver_data: sqlserver_data: