AcuarelaPortraits / build_frontend.sh
Alexramsal's picture
feat: add build_frontend.sh script for automatic frontend build on startup
a405d94
#!/bin/bash
# Build Frontend Script for Daggr on Hugging Face
# This script builds the frontend and is executed automatically on startup
set -e
echo "[*] Construyendo Frontend de Daggr en Hugging Face..."
# Navigate to frontend directory
if [ ! -d "/app/daggr/frontend" ]; then
echo "[ERROR] Frontend directory not found at /app/daggr/frontend"
exit 1
fi
cd /app/daggr/frontend
echo "[OK] Directorio: $(pwd)"
# Check if node_modules exists
if [ ! -d "node_modules" ]; then
echo "[*] Instalando dependencias npm..."
npm install --legacy-peer-deps
if [ $? -ne 0 ]; then
echo "[ERROR] Error installing dependencies"
exit 1
fi
else
echo "[OK] node_modules ya existe"
fi
# Build the frontend
echo "[*] Ejecutando: npm run build"
npm run build
if [ $? -ne 0 ]; then
echo "[ERROR] Error building frontend"
exit 1
fi
echo "[OK] Frontend construido exitosamente"
# Verify dist was created
if [ ! -d "dist" ]; then
echo "[ERROR] dist directory was not created"
exit 1
fi
echo ""
echo "[DONE] Frontend listo para usar!"
echo "[INFO] Ubicación: $(pwd)/dist"