betterbot/scripts/deploy-betterbot.sh

33 lines
944 B
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}"
SITE_DIR="${SITE_DIR:-/opt/betterlifesg/site}"
cd "$REPO_DIR"
git pull --ff-only origin master
mkdir -p "$STACK_DIR" "$SITE_DIR"
cp compose/docker-compose.yml "$STACK_DIR/docker-compose.yml"
# Seed .env from example if it doesn't exist
if [ ! -f "$STACK_DIR/.env" ]; then
cp compose/.env.example "$STACK_DIR/.env"
echo "WARNING: $STACK_DIR/.env created from template — edit it with real secrets."
fi
# Fetch secrets from Infisical if available
if [ -f /opt/config/infisical-agent.env ] && [ -f /opt/src/self_hosting/infra/scripts/infisical-env.sh ]; then
source /opt/src/self_hosting/infra/scripts/infisical-env.sh
infisical_fetch racknerd-betterbot "$STACK_DIR/.env"
fi
cd "$STACK_DIR"
docker compose build --pull
docker compose up -d
echo "BetterBot deployed."