Files
TallerCiCd/README.md
jose-rZM c3f7af7379 Init
2025-12-15 11:42:17 +01:00

67 lines
1.5 KiB
Markdown

# 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)
```bash
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:
```bash
cd backend
pip install -r requirements-dev.txt
pytest
ruff check app tests
```
Docker:
```bash
cd backend
docker build -t cafeteria-backend .
docker run -p 8000:8000 cafeteria-backend
```
## Frontend (Svelte)
```bash
cd frontend
npm install
npm run dev -- --host --port 5173
```
Tests, lint/check:
```bash
cd frontend
npm test # no, no voy a hacer tests de frontend
npm run check
```
Docker (sirve con nginx):
```bash
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.