fix: deploy script uses temp dir and includes frontend in zip

This commit is contained in:
NADAL Jean-Baptiste
2026-02-27 12:25:57 +01:00
parent 5275acc4ff
commit 75912d7ed3
2 changed files with 33 additions and 21 deletions

View File

@@ -8,43 +8,54 @@ cd /home/jbnadal/sources/jb/ohmj/ohmj2
echo "=== OHMJ Deploy Script ==="
# 1. Remove old zip
echo "[1/7] Removing old zip..."
rm -f _builds/deploy_ohmj.zip
# Create temp directory for deploy
DEPLOY_DIR="_deploy_temp"
rm -rf $DEPLOY_DIR
mkdir -p $DEPLOY_DIR
# 1. Copy source files
echo "[1/8] Copying source files..."
cp -r api $DEPLOY_DIR/
cp -r partitions $DEPLOY_DIR/
cp -r deploy $DEPLOY_DIR/
# 2. Generate JWT_SECRET
echo "[2/7] Generating JWT_SECRET..."
echo "[2/8] Generating JWT_SECRET..."
JWT_SECRET=$(openssl rand -base64 32)
echo "JWT_SECRET=$JWT_SECRET" > api/.env
echo "SCORES_PATH=/data/scores/" >> api/.env
echo "JWT_SECRET=$JWT_SECRET" > $DEPLOY_DIR/api/.env
echo "SCORES_PATH=/data/scores/" >> $DEPLOY_DIR/api/.env
# 3. Set production API URL in frontend .env
echo "[3/7] Setting production API URL..."
echo "VITE_API_URL=https://ohmj-api.c.nadal-fr.com" > partitions/.env
echo "[3/8] Setting production API URL..."
echo "VITE_API_URL=https://ohmj-api.c.nadal-fr.com" > $DEPLOY_DIR/partitions/.env
# 4. Clean and build frontend
echo "[4/7] Cleaning and building frontend..."
cd partitions
echo "[4/8] Cleaning and building frontend..."
cd $DEPLOY_DIR/partitions
rm -rf build
npm run build
# Copy .mjs to .js for correct MIME type
cp build/pdf.worker.min.mjs build/pdf.worker.min.js 2>/dev/null || echo "pdf.worker.min.mjs not found"
cd ..
cd ../..
# 5. Create symlink for frontend directory
echo "[5/7] Creating frontend symlink..."
rm -f frontend
ln -sfn partitions/build frontend
# 5. Copy built frontend as 'frontend' directory (not symlink, for zip compatibility)
echo "[5/8] Copying built frontend..."
cp -r $DEPLOY_DIR/partitions/build $DEPLOY_DIR/frontend
# 6. Copy nginx config to frontend
echo "[6/7] Adding nginx config..."
mkdir -p partitions/build
cp /home/jbnadal/sources/jb/ohmj/ohmj2/partitions/nginx.conf partitions/build/nginx.conf 2>/dev/null || echo "nginx.conf not found in partitions/"
echo "[6/8] Adding nginx config..."
cp partitions/nginx.conf $DEPLOY_DIR/frontend/nginx.conf 2>/dev/null || echo "nginx.conf not found"
# 7. Create zip (without tests.php and legacy)
echo "[7/7] Creating zip..."
zip -r _builds/deploy_ohmj.zip api frontend -x "*.DS_Store" "node_modules/*" ".svelte-kit/*" "api/tests.php"
echo "[7/8] Creating zip..."
cd $DEPLOY_DIR
zip -r ../_builds/deploy_ohmj.zip api frontend -x "*.DS_Store" "node_modules/*" ".svelte-kit/*" "api/tests.php"
# 8. Cleanup
echo "[8/8] Cleaning up..."
cd ..
rm -rf $DEPLOY_DIR
echo "=== Done! ==="
echo "Zip created: _builds/deploy_ohmj.zip"