22d75adea27774183e3e9f738325358de902d440
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
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 /healthestado.GET /menudevuelve el menú del día.GET /priceslista 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
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, pasaruffypytest. - Frontend:
npm install,npm run checkynpm test, luegonpm run build. - Docker: construye imágenes
cafeteria-backendycafeteria-frontendsi existen los Dockerfile. - Se despliegan las imágenes.
- En la aplicación se recupera el último commit y el autor.
Description
Languages
Svelte
36.2%
CSS
27.4%
Python
26%
JavaScript
7.3%
Dockerfile
2.4%
Other
0.7%