#!/bin/sh set -e APP_DIR=/var/www/app FRONTEND_DIR="$APP_DIR/apps/frontend" BACKEND_DIR="$APP_DIR/apps/backend" PUBLIC_DIR="$BACKEND_DIR/public" PHP_PORT=9000 /usr/local/bin/wait-for-it.sh "BACKEND_DIR:$PHP_PORT" -t 300 cd "$FRONTEND_DIR" npm ci --prefer-offline --no-audit npm run build if [ -d "$PUBLIC_DIR" ]; then find "$PUBLIC_DIR" -mindepth 1 \ ! -name 'index.php' \ ! -name '.htaccess' \ ! -name 'storage' \ -delete else mkdir -p "$PUBLIC_DIR" fi cp -r dist/* "$PUBLIC_DIR/" if [ -f "$PUBLIC_DIR/index.html" ]; then mkdir -p "$BACKEND_DIR/resources/views" cp "$PUBLIC_DIR/index.html" "$BACKEND_DIR/resources/views/app.blade.php" rm "$PUBLIC_DIR/index.html" fi if [ ! -L "$PUBLIC_DIR/storage" ] && [ ! -e "$PUBLIC_DIR/storage" ]; then ln -sfn "$BACKEND_DIR/storage/app/public" "$PUBLIC_DIR/storage" fi echo "[FRONTEND BUILD] Build React terminé et déployé dans $PUBLIC_DIR ✅" exit 0