From f1a26d80a828d50ad427d5e7724e252fcb716e27 Mon Sep 17 00:00:00 2001 From: katamaz Date: Fri, 2 Oct 2026 21:13:32 +0300 Subject: [PATCH] feat: docker --- .dockerignore | 13 +++++++++++++ Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yml | 11 +++++++++++ uv.lock | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5313823 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +# secrets - never bake the bot token into the image +config.ini + +# local junk +.venv +.git +.gitignore +__pycache__ +*.pyc +readme/ +.dockerignore +Dockerfile +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2198e02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim + +WORKDIR /app + +# Force uv to use the system Python instead of downloading its own +ENV UV_PYTHON_DOWNLOADS=never \ + UV_COMPILE_BYTECODE=1 \ + UV_LINK_MODE=copy \ + PYTHONUNBUFFERED=1 + +# Install locked dependencies first so code changes don't invalidate this layer +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-dev + +# Then copy the application itself +COPY main.py formater.py image.py ./ +COPY assets ./assets + +# Put the venv on PATH so `python` resolves to the venv interpreter +ENV PATH="/app/.venv/bin:$PATH" + +CMD ["python", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8449e87 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + bot: + build: + context: . + dockerfile: Dockerfile + container_name: confucius-quote-bot + environment: + - PYTHONUNBUFFERED=1 + volumes: + - ./config.ini:/app/config.ini:ro + restart: unless-stopped diff --git a/uv.lock b/uv.lock index 198b389..a6c9621 100644 --- a/uv.lock +++ b/uv.lock @@ -135,7 +135,7 @@ wheels = [ ] [[package]] -name = "confucius-citate-bot" +name = "confucius-quote-bot" version = "0.1.0" source = { virtual = "." } dependencies = [