From 7d10b688fc9623e0f3f32b79e39948951852826a Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Mon, 24 Aug 2026 15:34:00 +0300 Subject: [PATCH] fix(docker): install the project after its sources are copied pip install . ran with only pyproject.toml and uv.lock present, so setuptools found no packages: the api package, the api.mcp templates package-data and the console scripts never reached site-packages. Because a console script resolves imports from its own bin directory rather than the working directory, both entry points were broken in the image: cgraph BROKEN cgraph-mcp BROKEN which meant the documented CGRAPH_MODE=mcp path could not start at all. Web mode only worked because uvicorn adds the working directory to the import path. Split the install: dependencies come from the exported uv.lock requirements as before, keeping that layer cache-friendly, and the project itself is installed with --no-deps after ./api and README.md are copied. Verified on the built image: cgraph and cgraph-mcp both run from outside /app, the MCP server answers an initialize request, the templates ship in site-packages, and web mode still resolves STATIC_DIR to /app/app/dist and serves /api/list_repos with 200. Addresses review feedback on #723. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Dockerfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b170e82..730771bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,16 +37,16 @@ RUN apt-get update \ WORKDIR /app # Install Python dependencies pinned to uv.lock so the image matches CI. -# uv is pinned too: it produces the constraints file, so an unpinned +# uv is pinned too: it produces the requirements file, so an unpinned # upgrade could change `uv export` semantics and break reproducibility. # It is removed in the same layer, since only the export step needs it. ARG UV_VERSION=0.12.5 COPY pyproject.toml uv.lock ./ RUN pip install --no-cache-dir --break-system-packages "uv==${UV_VERSION}" \ - && uv export --frozen --no-dev --no-emit-project --no-hashes -o /tmp/constraints.txt \ + && uv export --frozen --no-dev --no-emit-project --no-hashes -o /tmp/requirements.txt \ && pip uninstall -y --break-system-packages uv \ - && pip install --no-cache-dir --break-system-packages -c /tmp/constraints.txt . \ - && rm /tmp/constraints.txt + && pip install --no-cache-dir --break-system-packages -r /tmp/requirements.txt \ + && rm /tmp/requirements.txt # Verify Node.js tooling for building the frontend RUN node --version && npm --version @@ -66,6 +66,13 @@ RUN npm --prefix ./app run build # Copy backend code COPY ./api ./api +# Install the project itself now that its sources (and the README the +# metadata references) are present, so the `api` package, its template +# package-data and the cgraph/cgraph-mcp entry points all land in +# site-packages. Dependencies are already installed and pinned above. +COPY README.md ./ +RUN pip install --no-cache-dir --break-system-packages --no-deps . + # Copy and make start.sh executable COPY start.sh /start.sh RUN chmod +x /start.sh