Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions scripts/deploy-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@
set -euo pipefail

if [[ $# -lt 2 ]]; then
echo "Usage: $0 <ssh-password> <telegram-bot-token> [ssh-host] [ssh-user] [telegram-bot-username] [mini-app-short-name] [public-origin]" >&2
echo "Usage: $0 <ssh-password> <telegram-bot-token> [ssh-host] [ssh-user] [public-origin]" >&2
exit 1
fi

SSH_PASSWORD="$1"
TELEGRAM_BOT_TOKEN="$2"
SSH_HOST="${3-spawn-dock.w3voice.net}"
SSH_USER="${4:-ops}"
TELEGRAM_BOT_USERNAME="${5-TMASpawnerBot}"
TELEGRAM_MINI_APP_SHORT_NAME="${6-tma}"
PUBLIC_ORIGIN="${7:-https://spawn-dock.w3voice.net}"
PUBLIC_ORIGIN="${5:-https://spawn-dock.w3voice.net}"
TARGET_DIR="/srv/spawndock-api"
BOT_SECRET="$(openssl rand -hex 24)"
BOT_CONTROL_PLANE_URL="http://mcp-server:3000"
PUBLIC_HOST=":80"
TELEGRAM_MINI_APP_SHORT_NAME="tma"

if [[ "$PUBLIC_ORIGIN" =~ ^https://([^/]+)$ ]]; then
PUBLIC_HOST="${BASH_REMATCH[1]}"
fi

TELEGRAM_BOT_USERNAME="$(
curl -fsS "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getMe" \
| python3 -c 'import json, sys; data = json.load(sys.stdin); result = data.get("result") or {}; username = result.get("username");
if not data.get("ok") or not username: raise SystemExit("Could not resolve Telegram bot username from token");
print(username, end="")'
)"

ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
TMP_ARCHIVE="$(mktemp /tmp/spawndock-api.XXXXXX.tar.gz)"
TMP_ENV="$(mktemp /tmp/spawndock-api.env.XXXXXX)"
Expand Down