docs: Add PostgreSQL remote connection configuration steps
- Add PostgreSQL remote connection setup section to DEPLOY_FROM_SCRATCH.md - Update deploy_from_scratch.sh to display PostgreSQL remote connection instructions - Remove blocking pause from deployment script (informational only) - Update admin-frontend API client to handle empty VITE_API_URL for proxy setups
This commit is contained in:
@@ -64,7 +64,58 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "== 3) Ensure env files exist (copied from *_example) =="
|
||||
echo "== 3) Configure firewall rules (optional) =="
|
||||
if command_exists ufw; then
|
||||
echo "Configure UFW firewall rules for application ports?"
|
||||
echo " - Port 3000 (Admin frontend)"
|
||||
echo " - Port 3001 (Viewer frontend)"
|
||||
echo " - Port 8000 (Backend API)"
|
||||
echo ""
|
||||
read -p "Add firewall rules? [y/N] " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
sudo ufw allow 3000/tcp
|
||||
sudo ufw allow 3001/tcp
|
||||
sudo ufw allow 8000/tcp
|
||||
echo "✅ Firewall rules added"
|
||||
else
|
||||
echo "⏭️ Skipped firewall rules (configure manually if needed)"
|
||||
fi
|
||||
else
|
||||
echo "⏭️ UFW not found, skipping firewall configuration"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "== 3.5) PostgreSQL Remote Connection Setup (if using remote database) =="
|
||||
echo "If your PostgreSQL database is on a separate server, you need to configure"
|
||||
echo "PostgreSQL to accept remote connections."
|
||||
echo ""
|
||||
echo "⚠️ IMPORTANT: This configuration must be done ON THE DATABASE SERVER."
|
||||
echo " Configure PostgreSQL before starting services (Step 11)."
|
||||
echo ""
|
||||
echo "Required steps on the DATABASE SERVER:"
|
||||
echo ""
|
||||
echo "1. Edit pg_hba.conf:"
|
||||
echo " sudo nano /etc/postgresql/*/main/pg_hba.conf"
|
||||
echo " Add line: host all all YOUR_APP_SERVER_IP/32 md5"
|
||||
echo ""
|
||||
echo "2. Edit postgresql.conf:"
|
||||
echo " sudo nano /etc/postgresql/*/main/postgresql.conf"
|
||||
echo " Set: listen_addresses = '*'"
|
||||
echo ""
|
||||
echo "3. Restart PostgreSQL:"
|
||||
echo " sudo systemctl restart postgresql"
|
||||
echo ""
|
||||
echo "4. Configure firewall on DB server:"
|
||||
echo " sudo ufw allow from YOUR_APP_SERVER_IP to any port 5432"
|
||||
echo ""
|
||||
echo "5. Test connection from this server:"
|
||||
echo " psql -h YOUR_DB_SERVER_IP -U YOUR_DB_USER -d postgres"
|
||||
echo ""
|
||||
echo "⏭️ Continuing with deployment. Ensure PostgreSQL is configured before Step 11."
|
||||
|
||||
echo ""
|
||||
echo "== 4) Ensure env files exist (copied from *_example) =="
|
||||
ensure_file_from_example "${PROJECT_ROOT}/.env_example" "${PROJECT_ROOT}/.env"
|
||||
ensure_file_from_example "${PROJECT_ROOT}/admin-frontend/.env_example" \
|
||||
"${PROJECT_ROOT}/admin-frontend/.env"
|
||||
@@ -81,7 +132,7 @@ echo "Press Enter once they are updated..."
|
||||
read -r
|
||||
|
||||
echo ""
|
||||
echo "== 4) Backend Python venv + deps =="
|
||||
echo "== 5) Backend Python venv + deps =="
|
||||
cd "${PROJECT_ROOT}"
|
||||
python3 -m venv venv
|
||||
./venv/bin/pip install --upgrade pip
|
||||
@@ -89,35 +140,62 @@ python3 -m venv venv
|
||||
echo "✅ Backend dependencies installed"
|
||||
|
||||
echo ""
|
||||
echo "== 5) Admin frontend deps =="
|
||||
echo "== 6) Admin frontend deps =="
|
||||
cd "${PROJECT_ROOT}/admin-frontend"
|
||||
npm ci
|
||||
echo "✅ Admin dependencies installed"
|
||||
|
||||
echo ""
|
||||
echo "== 6) Viewer frontend deps + Prisma clients =="
|
||||
echo "== 7) Viewer frontend deps + Prisma clients =="
|
||||
cd "${PROJECT_ROOT}/viewer-frontend"
|
||||
npm ci
|
||||
npm run prisma:generate:all
|
||||
echo "✅ Viewer dependencies installed and Prisma clients generated"
|
||||
|
||||
echo ""
|
||||
echo "== 7) Auth DB setup scripts (viewer) =="
|
||||
echo "== 8) Auth DB setup scripts (viewer) =="
|
||||
cd "${PROJECT_ROOT}/viewer-frontend"
|
||||
npx tsx scripts/setup-auth.ts
|
||||
npx tsx scripts/fix-admin-user.ts
|
||||
echo "✅ Auth DB setup done"
|
||||
|
||||
echo ""
|
||||
echo "== 8) Start services (PM2) =="
|
||||
echo "== 9) Build frontends =="
|
||||
echo "Building admin frontend..."
|
||||
cd "${PROJECT_ROOT}/admin-frontend"
|
||||
npm run build
|
||||
echo "✅ Admin frontend built"
|
||||
|
||||
echo ""
|
||||
echo "Building viewer frontend..."
|
||||
cd "${PROJECT_ROOT}/viewer-frontend"
|
||||
npm run build
|
||||
echo "✅ Viewer frontend built"
|
||||
|
||||
echo ""
|
||||
echo "== 10) Configure PM2 =="
|
||||
if ! command_exists pm2; then
|
||||
echo "Installing PM2..."
|
||||
sudo npm i -g pm2
|
||||
fi
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
ensure_file_from_example \
|
||||
"${PROJECT_ROOT}/ecosystem.config.js.example" \
|
||||
"${PROJECT_ROOT}/ecosystem.config.js"
|
||||
|
||||
echo ""
|
||||
echo "⚠️ IMPORTANT: Review and edit ${PROJECT_ROOT}/ecosystem.config.js"
|
||||
echo " Update paths (cwd, error_file, out_file, PYTHONPATH, PATH) for your server."
|
||||
echo ""
|
||||
read -p "Press Enter once ecosystem.config.js is configured (or to use defaults)..."
|
||||
|
||||
echo ""
|
||||
echo "== 11) Start services (PM2) =="
|
||||
cd "${PROJECT_ROOT}"
|
||||
pm2 start ecosystem.config.js
|
||||
pm2 save
|
||||
echo "✅ Services started with PM2"
|
||||
|
||||
echo ""
|
||||
echo "✅ Done."
|
||||
|
||||
Reference in New Issue
Block a user