Initial commit: Portal Auth Admin Dashboard
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
9
deploy/.env.server
Normal file
9
deploy/.env.server
Normal file
@@ -0,0 +1,9 @@
|
||||
# Auth DB (localhost on this host)
|
||||
DB_AUTH_HOST=127.0.0.1
|
||||
DB_AUTH_PORT=5432
|
||||
DB_AUTH_NAME=portal_auth
|
||||
DB_AUTH_USER=portal_user
|
||||
DB_AUTH_PASSWORD=REPLACE_WITH_ACTUAL_PASSWORD
|
||||
|
||||
# Dashboard
|
||||
SECRET_KEY=REPLACE_WITH_RANDOM_SECRET_KEY
|
||||
46
deploy/deploy.sh
Executable file
46
deploy/deploy.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Deploy Portal Auth Dashboard to root@10.110.60.210
|
||||
set -e
|
||||
TARGET="root@10.110.60.210"
|
||||
APP_DIR="/opt/portal-auth-dashboard"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
echo "=== Syncing files to $TARGET:$APP_DIR ==="
|
||||
ssh "$TARGET" "mkdir -p $APP_DIR"
|
||||
rsync -av \
|
||||
--exclude '.env' \
|
||||
--exclude '__pycache__' \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '.git' \
|
||||
--exclude 'venv' \
|
||||
"$PROJECT_DIR/app.py" \
|
||||
"$PROJECT_DIR/config.py" \
|
||||
"$PROJECT_DIR/db.py" \
|
||||
"$PROJECT_DIR/auth_helpers.py" \
|
||||
"$PROJECT_DIR/requirements.txt" \
|
||||
"$PROJECT_DIR/templates/" \
|
||||
"$PROJECT_DIR/static/" \
|
||||
"$PROJECT_DIR/deploy/" \
|
||||
"$TARGET:$APP_DIR/"
|
||||
|
||||
echo "=== Setting up Python venv and dependencies ==="
|
||||
ssh "$TARGET" "cd $APP_DIR && python3 -m venv venv && ./venv/bin/pip install -r requirements.txt"
|
||||
|
||||
echo "=== Ensuring .env exists (skip if already configured) ==="
|
||||
ssh "$TARGET" "if [ ! -f $APP_DIR/.env ]; then cp $APP_DIR/deploy/.env.server $APP_DIR/.env 2>/dev/null || echo 'DB_AUTH_HOST=127.0.0.1
|
||||
DB_AUTH_PORT=5432
|
||||
DB_AUTH_NAME=portal_auth
|
||||
DB_AUTH_USER=portal_user
|
||||
DB_AUTH_PASSWORD=
|
||||
SECRET_KEY=change-me' > $APP_DIR/.env; fi"
|
||||
|
||||
echo "=== Installing systemd unit ==="
|
||||
ssh "$TARGET" "cp $APP_DIR/deploy/portal-auth-dashboard.service /etc/systemd/system/ && systemctl daemon-reload && systemctl enable portal-auth-dashboard && systemctl restart portal-auth-dashboard"
|
||||
|
||||
echo "=== Status ==="
|
||||
ssh "$TARGET" "systemctl status portal-auth-dashboard --no-pager"
|
||||
|
||||
echo ""
|
||||
echo "Done. Dashboard: http://10.110.60.210:5000"
|
||||
echo "Edit $APP_DIR/.env on the server to set DB_AUTH_PASSWORD and SECRET_KEY, then: systemctl restart portal-auth-dashboard"
|
||||
17
deploy/portal-auth-dashboard.service
Normal file
17
deploy/portal-auth-dashboard.service
Normal file
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Portal Auth Admin Dashboard
|
||||
After=network.target postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/portal-auth-dashboard
|
||||
Environment="PATH=/opt/portal-auth-dashboard/venv/bin"
|
||||
ExecStart=/opt/portal-auth-dashboard/venv/bin/gunicorn -w 1 -b 0.0.0.0:5000 --access-logfile - --error-logfile - app:app
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user