From 1e258264135e4e693ba29f86f7b62ca0e4350f45 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Mon, 5 May 2025 10:23:49 +0200 Subject: [PATCH] Refactor configuration handling and add Docker Compose setup for botbotbot service --- Dockerfile | 1 + botbotbot/__init__.py | 5 ++++- compose.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 compose.yaml diff --git a/Dockerfile b/Dockerfile index da2a82a..6f4030a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-dev ENV PATH="/app/.venv/bin:$PATH" +ENV BOTBOTBOT_CONFIG="/config/config.toml" ENTRYPOINT [] diff --git a/botbotbot/__init__.py b/botbotbot/__init__.py index 0f8e024..3bbf8ad 100644 --- a/botbotbot/__init__.py +++ b/botbotbot/__init__.py @@ -1,4 +1,5 @@ import logging +import os import tomllib from typing import Any @@ -106,7 +107,9 @@ class ChaosBot: def main() -> None: logging.basicConfig(level=logging.INFO) - with open("config.toml", "rb") as config_file: + with open( + os.getenv("BOTBOTBOT_CONFIG", "/config/config.toml"), "rb" + ) as config_file: config = tomllib.load(config_file) chaos_bot = ChaosBot(config) diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..0ec915f --- /dev/null +++ b/compose.yaml @@ -0,0 +1,6 @@ +services: + botbotbot: + container_name: botbotbot + image: code.edgarpierre.fr/edpibu/botbotbot:main + volumes: + - /docker/botbotbot/config:/config