56 lines
1.5 KiB
Bash
Executable File
56 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# OHMJ Deployment Script
|
|
|
|
set -e
|
|
|
|
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
|
|
|
|
# 2. Generate JWT_SECRET
|
|
echo "[2/7] Generating JWT_SECRET..."
|
|
JWT_SECRET=$(openssl rand -base64 32)
|
|
echo "JWT_SECRET=$JWT_SECRET" > api/.env
|
|
echo "SCORES_PATH=/data/scores/" >> 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
|
|
|
|
# 4. Clean and build frontend
|
|
echo "[4/7] Cleaning and building frontend..."
|
|
cd 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 ..
|
|
|
|
# 5. Create symlink for frontend directory
|
|
echo "[5/7] Creating frontend symlink..."
|
|
rm -f frontend
|
|
ln -sfn partitions/build 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/"
|
|
|
|
# 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/*"
|
|
|
|
echo "=== Done! ==="
|
|
echo "Zip created: _builds/deploy_ohmj.zip"
|
|
echo ""
|
|
echo "To deploy:"
|
|
echo " 1. Upload zip to server"
|
|
echo " 2. Extract to /var/www/"
|
|
echo " 3. Configure web server"
|