# ─────────────────────────────────────────────────────────────────────────────
# Alvin Bot — docker compose for a VPS
#
#   1. edit .env            (BOT_TOKEN, ALLOWED_USERS, one AI provider)
#   2. docker compose up -d
#   3. docker compose logs -f
#
# Upgrade to a newer bot release:
#   docker compose build --pull --no-cache && docker compose up -d
# ─────────────────────────────────────────────────────────────────────────────
services:
  alvin-bot:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        # Pin a version here for a reproducible image, e.g. "5.88.0".
        ALVIN_VERSION: ${ALVIN_VERSION:-latest}
    image: alvin-bot:local
    container_name: alvin-bot
    restart: unless-stopped
    env_file: .env

    environment:
      # Cron jobs fire on the CONTAINER's clock, which is UTC unless told
      # otherwise. Someone who schedules a 08:00 reminder in Berlin and gets it
      # at 10:00 has not found a bug — they have found this line. Set TZ in
      # .env to your own zone.
      TZ: ${TZ:-UTC}

    volumes:
      # A NAMED volume, not ./data. The container runs unprivileged (uid 1000);
      # a bind mount would arrive owned by whoever created the host directory —
      # usually root — and the bot could not write its own state. If you prefer
      # a bind mount for easy backups, create the directory first and chown it
      # to 1000:1000.
      - alvin-data:/data

    ports:
      # Bound to LOOPBACK on purpose. The Web UI is a full control surface for
      # the bot; published as 0.0.0.0 it would be reachable from the whole
      # internet the moment the container starts.
      #
      # To reach it: SSH tunnel from your machine —
      #   ssh -N -L 3100:127.0.0.1:3100 user@your-vps
      # then open http://127.0.0.1:3100
      #
      # To expose it properly instead: put a reverse proxy with TLS in front,
      # and set a strong WEB_PASSWORD in .env first. Publishing this port
      # without a password is the single easiest way to hand over your bot.
      - "127.0.0.1:3100:3100"

    # An unrotated container log fills a VPS disk quietly and then everything
    # fails at once, in ways that look unrelated.
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"

volumes:
  alvin-data:
