Skip to content

Deployment

c0bra edited this page Jul 24, 2026 · 1 revision

Deployment

This page is for operators deploying Battlevive Bot with Docker or Podman Compose.

Requirements

  • Docker or Podman with Compose support.
  • A Discord bot token.
  • Battlevive/Supabase API credentials.
  • PostgreSQL credentials for the local database container.

Do not commit or paste real .env files or tokens. Use utils/.env.example as the template.

Environment file

From utils/.env.example, the deployment expects values for:

  • DISCORD_TOKEN
  • SUPABASE_URL
  • SUPABASE_API_KEY
  • BATTLEVIVE_URL
  • LOG_LEVEL
  • DISCORD_LOG_LEVEL
  • POSTGRES_USER
  • POSTGRES_PASSWORD
  • POSTGRES_DB
  • DATABASE_URL

DATABASE_URL points at the Compose database service by default: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}.

Initial setup

cd utils
cp .env.example .env
# fill required values in .env
./init.sh

init.sh installs helper dependencies and runs the environment generator/finalizer. Follow its prompts before starting the containers.

Running with Compose

From the repository root after setup:

docker compose up -d --build

or with Podman:

podman compose up -d --build

To build and recreate only the bot service when the database is already running:

podman compose up -d --build --no-deps bot

If podman-compose is installed and preferred, use equivalent podman-compose commands.

Check logs with:

docker compose logs -f bot
podman compose logs -f bot

Services and persisted data

Compose defines two services:

  • bot, built as image battlevive-bot:local, using .env and mounting ./app/data:/app/data and ./app/logs:/app/logs.
  • db, using postgres:18, loading bootstrap SQL from ./app/init-db, storing PostgreSQL data under ./app/data/postgresql, and binding PostgreSQL to 127.0.0.1:5432 for local host access only.

The database service has a pg_isready healthcheck, and the bot waits for the database to become healthy before starting.

Standalone image build

podman build . --file Dockerfile --tag battlevive-bot:local

or:

docker build . --file Dockerfile --tag battlevive-bot:local

Database migrations

Fresh database volumes run all files in app/init-db/ automatically. Existing PostgreSQL volumes do not rerun container initialization scripts automatically. Apply any missing numbered migrations manually and in order as a database administrator.

Known idempotent migrations for existing volumes include:

psql "$DATABASE_URL" -f app/init-db/04_guild_config.sql
psql "$DATABASE_URL" -f app/init-db/05_leaderboards.sql
psql "$DATABASE_URL" -f app/init-db/06_leaderboard_disk_cache.sql

Migration 06_leaderboard_disk_cache.sql removes database-stored PNG data, clamps leaderboard limits above 50, and enforces the 1-50 range.

See Database Schema for the schema and persistence notes.

Clone this wiki locally