sync current state
This commit is contained in:
@@ -4,7 +4,12 @@
|
||||
"Bash(/Users/felixfoertsch/Developer/TelegramStickersDownloaderHTTP/.venv/bin/pip list:*)",
|
||||
"Bash(.venv/bin/pip install:*)",
|
||||
"Bash(python3:*)",
|
||||
"Bash(.venv/bin/python:*)"
|
||||
"Bash(.venv/bin/python:*)",
|
||||
"WebFetch(domain:manual.uberspace.de)",
|
||||
"Bash(chmod +x:*)",
|
||||
"WebFetch(domain:lab.uberspace.de)",
|
||||
"WebSearch",
|
||||
"WebFetch(domain:u8manual.uberspace.de)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.routers import stickersets
|
||||
|
||||
app = FastAPI(title="Telegram Stickers API", root_path="/StiggerDLBot")
|
||||
app = FastAPI(title="Telegram Stickers API")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
84
StiggerDLBot/deploy.sh
Executable file
84
StiggerDLBot/deploy.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.sh — deploy sticker-cloner backend to Uberspace 8
|
||||
# Usage: ./deploy.sh
|
||||
set -euo pipefail
|
||||
|
||||
# ── Configuration — edit before first deploy ──────────────────────────────────
|
||||
UBERSPACE_USER="serve"
|
||||
UBERSPACE_NODE="prospero.uberspace.de" # SSH node (uberspace dashboard → hostname)
|
||||
PORT=8080
|
||||
URL_PATH="/sticker-cloner"
|
||||
SERVICE_NAME="sticker-cloner"
|
||||
|
||||
# ── Derived ───────────────────────────────────────────────────────────────────
|
||||
REMOTE="${UBERSPACE_USER}@${UBERSPACE_NODE}"
|
||||
WEB_HOST="${UBERSPACE_USER}.uber.space"
|
||||
REMOTE_APP_DIR="/home/${UBERSPACE_USER}/services/${SERVICE_NAME}"
|
||||
|
||||
# ── 1. Sync source files ──────────────────────────────────────────────────────
|
||||
echo "→ syncing app files..."
|
||||
rsync -az --delete \
|
||||
--exclude '.env' \
|
||||
--exclude '.venv/' \
|
||||
--exclude 'downloads/' \
|
||||
--exclude '.cache/' \
|
||||
--exclude '__pycache__/' \
|
||||
--exclude '*.pyc' \
|
||||
--exclude '.DS_Store' \
|
||||
--exclude '.git/' \
|
||||
--exclude '.idea/' \
|
||||
--exclude '.vscode/' \
|
||||
--exclude 'deploy.sh' \
|
||||
. "${REMOTE}:${REMOTE_APP_DIR}/"
|
||||
|
||||
# ── 2. Upload .env ────────────────────────────────────────────────────────────
|
||||
echo "→ uploading .env..."
|
||||
scp .env "${REMOTE}:${REMOTE_APP_DIR}/.env"
|
||||
|
||||
# ── 3. Push systemd service unit ──────────────────────────────────────────────
|
||||
echo "→ writing service unit..."
|
||||
ssh "${REMOTE}" "mkdir -p ~/.config/systemd/user"
|
||||
cat <<EOF | ssh "${REMOTE}" "cat > ~/.config/systemd/user/${SERVICE_NAME}.service"
|
||||
[Unit]
|
||||
Description=sticker-cloner backend
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=${REMOTE_APP_DIR}
|
||||
ExecStart=${REMOTE_APP_DIR}/.venv/bin/uvicorn app.main:app --host 0.0.0.0 --port ${PORT} --root-path ${URL_PATH}
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
|
||||
# ── 4. Remote provisioning ────────────────────────────────────────────────────
|
||||
echo "→ provisioning..."
|
||||
# XDG_RUNTIME_DIR is required for systemctl --user in non-interactive SSH sessions
|
||||
ssh "${REMOTE}" bash -l <<ENDSSH
|
||||
set -euo pipefail
|
||||
export XDG_RUNTIME_DIR="/run/user/\$(id -u)"
|
||||
cd "${REMOTE_APP_DIR}"
|
||||
|
||||
# Persistent runtime directories (never overwritten by rsync)
|
||||
mkdir -p downloads .cache
|
||||
|
||||
# Python venv
|
||||
[[ -d .venv ]] || python3 -m venv .venv
|
||||
.venv/bin/pip install --quiet --upgrade pip
|
||||
.venv/bin/pip install --quiet -r requirements.txt
|
||||
|
||||
# Reload unit files, enable on boot, start or restart
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable ${SERVICE_NAME}
|
||||
systemctl --user restart ${SERVICE_NAME}
|
||||
|
||||
# Configure web backend (idempotent via --force)
|
||||
# --remove-prefix strips ${URL_PATH} before forwarding, so FastAPI
|
||||
# routes (/api/stickersets/…) match without the prefix.
|
||||
uberspace web backend add ${URL_PATH} port ${PORT} --remove-prefix --force
|
||||
ENDSSH
|
||||
|
||||
echo ""
|
||||
echo "✓ deployed!"
|
||||
echo " health: https://${WEB_HOST}${URL_PATH}/health"
|
||||
echo " api: https://${WEB_HOST}${URL_PATH}/api/stickersets/{pack_name}"
|
||||
Reference in New Issue
Block a user