feat(docker): añadir Dockerfile para contenerizar la aplicación

This commit is contained in:
unknown
2026-06-11 16:05:10 -04:00
parent 74a67fbab2
commit 2a58693d31
70 changed files with 3826 additions and 874 deletions

129
README.md
View File

@@ -1,36 +1,123 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# Ferco Admin — Panel administrador de remates ganaderos
## Getting Started
Frontend React 18 + Vite + TypeScript para gestionar el backend Spring Boot de remates en vivo. Consume la API REST, WebSocket nativo (`/ws/**`) y SSE (`/api/webflux/lotes/stream/*`).
First, run the development server:
## Requisitos
- [Bun](https://bun.sh) 1.x (o Node.js 18+ con `npm`)
## Instalación
Con Bun (recomendado en este repo):
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
bun install
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Con npm:
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
```bash
npm install
```
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Variables de entorno
## Learn More
Copie `.env.example` a `.env`:
To learn more about Next.js, take a look at the following resources:
| Variable | Descripción |
|----------|-------------|
| `VITE_API_URL` | URL base del backend **sin** barra final. Ej: `https://testapp.digitaltelecom.net`. Si está **vacía**, las peticiones usan el mismo origen (recomendado en dev con el proxy de Vite). |
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
## Desarrollo
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
```bash
bun run dev
# o: npm run dev
```
## Deploy on Vercel
Abre [http://localhost:5173](http://localhost:5173).
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Sin `VITE_API_URL`, Vite hace proxy de `/api`, `/auth`, `/contador` y `/ws` hacia `https://testapp.digitaltelecom.net` (configurable en `vite.config.ts`).
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
## Producción
```bash
bun run build
bun run preview
# o: npm run build && npm run preview
```
Despliegue: sirva la carpeta `dist/` en el mismo dominio que la API o configure CORS en el backend.
## Docker
Imagen multi-etapa: **Bun** compila el frontend y **nginx** sirve los estáticos.
```bash
# Con docker compose (recomendado)
docker compose up -d --build
# Panel en http://localhost:8080
```
Variables en `docker-compose.yml` o en un `.env` junto al compose:
| Variable | Default | Descripción |
|----------|---------|-------------|
| `VITE_API_URL` | `https://testapp.digitaltelecom.net` | URL del backend (se embebe en el build) |
| `APP_PORT` | `8080` | Puerto expuesto en el host |
Build manual:
```bash
docker build \
--build-arg VITE_API_URL=https://testapp.digitaltelecom.net \
-t ferco-admin:latest .
docker run -d -p 8080:80 --name ferco-admin ferco-admin:latest
```
> **Nota:** `VITE_API_URL` se define en **tiempo de build**. Si cambia la API, reconstruya la imagen (`docker compose up -d --build`).
## Autenticación
- Login: `POST /api/usuarios/login` (email + contraseña).
- Token JWT en `localStorage` (`ferco_admin_token`).
- Rutas del panel protegidas; `401` cierra sesión y redirige a `/login`.
- Solo usuarios **aprobados** (`confirmed: true`) pueden entrar.
## Módulos
| Ruta | Función |
|------|---------|
| `/` | Dashboard con totales y accesos rápidos |
| `/usuarios` | Listado, aprobación de pendientes, edición, eliminación |
| `/cabanas` | CRUD cabañas |
| `/remates` | CRUD remates, finalizar remate, indicador WS eventos |
| `/lotes` | CRUD lotes, suscripción SSE opcional por lote |
| `/pujas` | Listado, filtros, informes por remate |
| `/en-vivo` | Sala operador: contador WS/REST, reset, corregir, FIN_REMATE, pujas en vivo |
| `/historial` | `GET /api/HistorialPujas` |
## Tiempo real
- **Contador:** `wss://…/ws/puja/{remateId}/{loteId}` + REST `/contador/*`
- **Eventos remate:** `wss://…/ws/eventos/{remateId}` → mensaje `FIN_REMATE`
- **SSE lotes:** `GET /api/webflux/lotes/stream/{loteId}` con header `Authorization: Bearer …`
## Estructura
```
src/
api/ Cliente HTTP y endpoints
auth/ AuthContext, PrivateRoute
hooks/ useWebSocket, useContador, useEventosRemate, useLoteSSE
pages/ Pantallas del panel
components/ Layout, Sidebar, DataTable, Modal, etc.
types/ Interfaces TypeScript
utils/ URLs, fechas
```
## Backend de referencia
Producción: `https://testapp.digitaltelecom.net`