Dashboard Leads - version limpia para servidor (.env y config de despliegue restaurados)

This commit is contained in:
Panchito
2026-08-20 11:00:14 -05:00
parent 514bcbda45
commit 9a73e95ae5
4 changed files with 99 additions and 0 deletions

36
docker-compose.yml Normal file
View File

@@ -0,0 +1,36 @@
# ============================================================
# Dashboard Leads - despliegue con Docker Compose (EasyPanel)
#
# backend : FastAPI + uvicorn en el puerto 8001
# (lee sus credenciales de backend/.env, incluido en la imagen)
# frontend: build de Vite servido por nginx en el puerto 80
#
# En EasyPanel, apunta los dominios a:
# api-leads.escueladerefrigeracion.lat -> backend : 8001
# dashboard-leads.escueladerefrigeracion.lat -> frontend : 80
# ============================================================
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
expose:
- "8001"
healthcheck:
test: ["CMD-SHELL", "python -c \"import urllib.request;urllib.request.urlopen('http://127.0.0.1:8001/api/health')\" || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
restart: unless-stopped
expose:
- "80"
depends_on:
- backend

6
frontend/.dockerignore Normal file
View File

@@ -0,0 +1,6 @@
node_modules
dist
.env.local
npm-debug.log*
Dockerfile
.dockerignore

20
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
# ── Etapa 1: build del frontend con Vite ──
FROM node:20-alpine AS build
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --no-audit --no-fund || npm install --no-audit --no-fund
COPY . .
RUN npm run build
# ── Etapa 2: servir el build con nginx ──
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

37
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,37 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Compresion
gzip on;
gzip_types text/plain text/css application/json application/javascript
text/xml application/xml application/xml+rss text/javascript
image/svg+xml;
gzip_min_length 1024;
# Cache larga para los assets con hash en el nombre
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# SPA: cualquier ruta desconocida devuelve index.html
location / {
try_files $uri $uri/ /index.html;
}
# index.html nunca se cachea, para que los deploys se vean al instante
location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
internal;
}
}