Add Dockerfile and nginx config for frontend

This commit is contained in:
Motoko
2026-03-30 15:33:32 +00:00
parent c9cb07dbfc
commit 329f7509f5
2 changed files with 59 additions and 0 deletions

29
Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copiar archivos de configuración
COPY package.json package-lock.json ./
# Instalar dependencias
RUN npm ci
# Copiar código fuente
COPY . .
# Build de la aplicación
RUN npm run build
# Production stage
FROM nginx:alpine
# Copiar archivos del build
COPY --from=builder /app/dist /usr/share/nginx/html
# Copiar configuración de nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

30
nginx.conf Normal file
View File

@@ -0,0 +1,30 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Servir archivos estáticos
location / {
try_files $uri $uri/ /index.html;
}
# Proxy para la API
location /api/ {
proxy_pass http://backend:8000/api/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
# Configuración de caché para archivos estáticos
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}