2025-12-28 11:34:30 +01:00
2025-12-28 11:01:55 +01:00
2025-12-24 12:44:34 +01:00
2025-12-28 11:05:24 +01:00
2025-12-16 09:19:02 +01:00
2025-12-24 12:44:34 +01:00

Taller CI/CD con Jenkins - Proyecto base

  • backend/: API con FastAPI.
  • frontend/: interfaz en Svelte (Vite).

Requisitos locales

  • Python 3.11+ y pip
  • Node 18+ y npm

Configuracion de entorno (local/prod)

Variables que usa docker-compose y el frontend:

cp .env.example .env

Notas:

  • VITE_API_BASE por defecto apunta a /taller/api y el frontend proxya a la API.
  • Para Jenkins local en contenedor: JENKINS_BASE_URL=http://jenkins:8080. Se hace necesario que back y jenkins estén en la misma red de Docker si se quiere probar en local.
  • Para VPS: JENKINS_BASE_URL=https://openbokeron.org/jenkins.

Backend (FastAPI)

cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

Endpoints:

  • GET /health estado.
  • GET /menu devuelve el menú del día.
  • GET /prices lista de precios aleatorios.
  • GET /prices/{item} precio aleatorio para un item concreto.

Tests y lint:

cd backend
pip install -r requirements-dev.txt
pytest
ruff check app tests

Docker:

cd backend
docker build -t cafeteria-backend .
docker run -p 8000:8000 cafeteria-backend

Frontend (Svelte)

cd frontend
npm install
npm run dev -- --host --port 5173

Abrir http://localhost:5173/taller/. Tests, lint/check:

cd frontend
npm test # no, no voy a hacer tests de frontend
npm run check

Docker (sirve con nginx):

cd frontend
docker build -t cafeteria-frontend .
docker run -p 8080:80 cafeteria-frontend

Jenkinsfile (pipeline)

Incluido Jenkinsfile declarativo para ejecutar en un agente cualquiera con Python 3.11+, Node 18+ y Docker:

  • Backend: crea entorno virtual, instala requirements-dev, pasa ruff y pytest.
  • Frontend: npm install, npm run check y npm test, luego npm run build.
  • Docker: construye imágenes cafeteria-backend y cafeteria-frontend si existen los Dockerfile.
  • Se despliegan las imágenes.
  • En la aplicación se recupera el último commit y el autor.
Description
No description provided
Readme 431 KiB
Languages
Svelte 35%
CSS 26.5%
Python 26.4%
JavaScript 8.9%
Dockerfile 2.6%
Other 0.6%