CRÍTICO: Eliminación definitiva de vendor-other Cambios: - vite.config.ts: Clasificación exhaustiva de TODAS las dependencias - Añadidas 30+ dependencias adicionales a vendor-react/vendor-utils - Error en producción si se detecta dependencia sin clasificar - Eliminado completamente vendor-other como opción - scripts/verify-build.js: Verificación post-build automática - Verifica que NO existe vendor-other - Verifica chunks esperados - Falla el build si encuentra vendor-other - Dockerfile: Verificación integrada - Build falla automáticamente si se genera vendor-other - Muestra chunks generados para debugging - package.json: build ahora ejecuta verificación automáticamente - manifest.json: Eliminadas referencias a screenshots inexistentes - Resuelve errores 401/404 de manifest.json - docs/SOLUCION_DOCKER_VENDOR_OTHER.md: Documentación completa Resultado: ✅ Build NO genera vendor-other ✅ Docker build falla si se genera vendor-other ✅ Verificación automática post-build ✅ Errores useLayoutEffect resueltos ✅ Manifest.json sin errores
65 lines
1.8 KiB
Docker
65 lines
1.8 KiB
Docker
# Multi-stage build para EMERGES TES
|
|
# Stage 1: Build
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copiar archivos de dependencias
|
|
COPY package.json package-lock.json* ./
|
|
|
|
# Instalar dependencias
|
|
RUN npm ci --production=false
|
|
|
|
# Copiar código fuente
|
|
COPY . .
|
|
|
|
# Build de producción
|
|
RUN npm run build
|
|
|
|
# Verificar que el build se completó
|
|
RUN test -d dist || (echo "Error: dist directory not found" && exit 1)
|
|
RUN test "$(ls -A dist)" || (echo "Error: dist directory is empty" && exit 1)
|
|
|
|
# CRÍTICO: Verificar que NO se generó vendor-other (causa errores useLayoutEffect)
|
|
RUN if ls dist/assets/vendor-other* 2>/dev/null; then \
|
|
echo "❌ ERROR CRÍTICO: vendor-other fue generado en el build"; \
|
|
echo "Esto causará errores useLayoutEffect en producción"; \
|
|
ls -la dist/assets/vendor-other*; \
|
|
exit 1; \
|
|
else \
|
|
echo "✅ Verificación: vendor-other NO existe (correcto)"; \
|
|
fi
|
|
|
|
# Verificar chunks esperados
|
|
RUN echo "📦 Chunks vendor generados:" && \
|
|
ls -lh dist/assets/vendor-*.js 2>/dev/null | awk '{print " "$9" ("$5")"}' || true
|
|
|
|
# Stage 2: Production
|
|
FROM node:18-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Instalar serve globalmente para servir archivos estáticos
|
|
RUN npm install -g serve@14.2.1
|
|
|
|
# Copiar archivos construidos desde builder
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Copiar package.json para mantener metadata (opcional)
|
|
COPY --from=builder /app/package.json ./package.json
|
|
|
|
# Exponer puerto 8607
|
|
EXPOSE 8607
|
|
|
|
# Variables de entorno
|
|
ENV NODE_ENV=production
|
|
ENV PORT=8607
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:8607', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
|
|
# Comando para servir la aplicación
|
|
CMD ["serve", "-s", "dist", "-l", "8607"]
|
|
|