betterbot/scripts/deploy-betterbot.sh
Andre K e68c84424f
Some checks failed
Deploy BetterBot / deploy (push) Failing after 3s
Deploy BetterBot / notify (push) Successful in 3s
feat: fork from CodeAnywhere framework
Replace standalone Telegram bot with full CodeAnywhere framework fork.
BetterBot shares all framework code and customizes only:
- instance.py: BetterBot identity, system prompt, feature flags
- tools/site_editing/: list_files, read_file, write_file with auto git push
- .env: model defaults and site directory paths
- compose/: Docker setup with betterlifesg + memoraiz mounts
- deploy script: RackNerd with Infisical secrets
2026-04-19 08:01:27 +08:00

48 lines
2.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# Deploy BetterBot to RackNerd.
REPO_DIR="${REPO_DIR:-/opt/src/betterbot}"
STACK_DIR="${STACK_DIR:-/opt/betterbot}"
CONFIG_DIR="${CONFIG_DIR:-/opt/config}"
cd "$REPO_DIR"
git pull --ff-only origin master
# ── Copy compose ────────────────────────────────────────────────────
mkdir -p "$STACK_DIR"
cp "$REPO_DIR/compose/docker-compose.yml" "$STACK_DIR/docker-compose.yml"
# ── Seed defaults from committed .env ───────────────────────────────
cp "$REPO_DIR/.env" "$STACK_DIR/defaults.env"
# ── First-run guard ─────────────────────────────────────────────────
if [ ! -f "$STACK_DIR/.env" ]; then
cp "$REPO_DIR/compose/.env.example" "$STACK_DIR/.env"
echo "⚠ First deploy — edit $STACK_DIR/.env with real secrets, then re-run."
exit 0
fi
# ── Fetch secrets from Infisical ────────────────────────────────────
INFISICAL_AGENT_ENV="$CONFIG_DIR/infisical-agent.env"
if [ -f "$INFISICAL_AGENT_ENV" ]; then
INFRA_DIR="${INFRA_DIR:-/opt/src/self_hosting/infra}"
source "$INFRA_DIR/scripts/infisical-env.sh"
infisical_fetch racknerd-betterbot "$STACK_DIR/.env" prod || echo "Warning: Infisical fetch failed, using existing .env"
fi
# ── Configure git identity for site repos ───────────────────────────
for repo_dir in /opt/src/betterlifesg /opt/src/hk_memoraiz; do
if [ -d "$repo_dir/.git" ]; then
git -C "$repo_dir" config user.email "betterbot@bytesizeprotip.com"
git -C "$repo_dir" config user.name "BetterBot"
fi
done
# ── Deploy ──────────────────────────────────────────────────────────
cd "$STACK_DIR"
docker compose build --pull
docker compose up -d
echo "BetterBot deployed."