Reviewed-on: #18
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_BASEpor defecto apunta a/taller/apiy 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 /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
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, 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
35%
CSS
26.5%
Python
26.4%
JavaScript
8.9%
Dockerfile
2.6%
Other
0.6%