Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ FROM python:3.12-bookworm
RUN apt-get update \
&& apt-get install -y python3-dev default-libmysqlclient-dev build-essential pkg-config

COPY . /python-api
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN python -m pip install uv

WORKDIR /python-api
COPY pyproject.toml .

RUN uv pip install -e ".[dev]"
COPY . /python-api
Comment on lines +13 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Editable install will fail due to missing source code.

The editable install (-e) on line 15 requires the full package structure to be present, but only pyproject.toml is copied at line 13. The source code is copied at line 16, after the installation attempt. This will cause the Docker build to fail.

Additionally, editable installs are typically used in development environments where you want changes to the source code to be immediately reflected without reinstalling. In a Docker container, this benefit doesn't apply since the container image is immutable.

🔎 Proposed fix: Remove the `-e` flag for regular installation
-RUN uv pip install -e ".[dev]"
+RUN uv pip install ".[dev]"
 COPY . /python-api

This change:

  • Performs a regular (non-editable) installation using only pyproject.toml
  • Maintains the layer caching benefit (dependencies are cached separately from source code)
  • Copies the source code afterward, which is the correct order for non-editable installs
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
COPY pyproject.toml .
RUN uv pip install -e ".[dev]"
COPY . /python-api
COPY pyproject.toml .
RUN uv pip install ".[dev]"
COPY . /python-api
🤖 Prompt for AI Agents
In docker/python/Dockerfile around lines 13 to 16, the Dockerfile attempts an
editable install (pip install -e) before copying the package source, which will
fail because the source code isn't present; change the install to a regular
non-editable install (remove -e) so dependencies are installed from
pyproject.toml and keep the COPY . /python-api after to preserve layer caching
and then install final package if needed after copying source or simply install
non-editably before copying source as proposed.


RUN python -m pip install --upgrade pip
RUN python -m pip install -e ".[dev]"

EXPOSE 8000
ENTRYPOINT ["python", "src/main.py"]
Expand Down