From efd92a9312077a2e2fd9d167af6666486d50729e Mon Sep 17 00:00:00 2001 From: DzEuSkiNG Date: Fri, 30 Oct 2026 18:29:18 +0000 Subject: [PATCH] build: keep pytest out of the production backend image pytest and pytest-asyncio were runtime dependencies in backend/pyproject.toml, so 'pip install .' in backend/Dockerfile shipped the test framework in every production image. Move them to an optional 'test' extra and install it only when the INSTALL_TEST_DEPS build arg is 'true', which docker-compose.test.yml sets for CI. The production compose files build with the default (false). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016g7tG1VzB5Xnr8GJ7rGDti --- backend/Dockerfile | 6 +++++- backend/pyproject.toml | 6 +++++- docker-compose.test.yml | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index fe98608..bdbfb19 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -15,8 +15,12 @@ RUN adduser --disabled-password --gecos "" --uid 1001 ghostbill COPY pyproject.toml . +# Test tooling is opt-in so it never ships in the production image. +# docker-compose.test.yml sets INSTALL_TEST_DEPS=true for CI. +ARG INSTALL_TEST_DEPS=false RUN pip install --no-cache-dir --upgrade pip \ - && pip install --no-cache-dir . + && if [ "$INSTALL_TEST_DEPS" = "true" ]; then pip install --no-cache-dir ".[test]"; \ + else pip install --no-cache-dir .; fi COPY . . diff --git a/backend/pyproject.toml b/backend/pyproject.toml index c11939d..3b55340 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -16,9 +16,13 @@ dependencies = [ "bcrypt>=4.2.0", "cryptography>=44.0.0", "python-multipart>=0.0.12", + "segno>=1.6.0", +] + +[project.optional-dependencies] +test = [ "pytest>=9.0.3", "pytest-asyncio>=0.24.0", - "segno>=1.6.0", ] [build-system] diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 7d4d2e9..6c9c6c3 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -43,6 +43,8 @@ services: build: context: ./backend dockerfile: Dockerfile + args: + INSTALL_TEST_DEPS: "true" env_file: - .env.test depends_on: