Skip to content

replace poetry with uv in docker - #30

Merged
heinrich10 merged 2 commits into
mainfrom
refactor/docker_file
Jun 4, 2026
Merged

replace poetry with uv in docker#30
heinrich10 merged 2 commits into
mainfrom
refactor/docker_file

Conversation

@heinrich10

Copy link
Copy Markdown
Owner

What?

Switches the Dockerfile from Poetry to uv, aligning the container build with the project's current package manager (uv.lock is the source of truth; poetry.lock does not exist). Also updates related documentation (README.md, AGENTS.md, architecture.md) to reflect the new build process.

Key changes:

  • Dockerfile: Replaced the multi-stage Poetry build with a single-stage uv build.
  • README.md: Removed the "WIP" label from the container section and updated commands to use docker by default.
  • AGENTS.md: Updated the Deployment section and removed the outdated note about Poetry references.
  • architecture.md: Marked the P3 task "Dockerfile: switch from Poetry to uv" as completed.

Why?

  • The previous Dockerfile referenced poetry.lock, which does not exist in the repository. The project has already migrated to uv (CI uses uv sync, uv.lock is present).
  • Keeping Poetry in the Dockerfile caused confusion for anyone trying to build the image and was flagged as a structural gap in architecture.md.
  • Using uv in Docker gives us faster installs, better layer caching via uv sync, and a smaller, simpler image.

How?

Dockerfile changes

  • Base image: Updated from python:3.12.1-bookworm/slim-bookworm to python:3.12.12-slim-bookworm (matching .python-version).
  • Simplified to single-stage: Removed the separate builder/runtime stages since all dependencies are pure Python wheels and uv installs quickly.
  • Installs uv: RUN pip install --no-cache-dir uv
  • Layer-cached dependency install:
    1. Copy pyproject.toml + uv.lockuv sync --frozen --no-dev --no-install-project
    2. Copy source code → uv sync --frozen --no-dev
  • Entrypoint: Uses uv run --no-sync to ensure the virtualenv is activated correctly without re-verifying the lockfile at runtime:
    ENTRYPOINT ["/bin/sh", "-c", "uv run --no-sync alembic upgrade head && uv run --no-sync python -m run"]

Documentation updates

  • README.md: Container instructions are no longer "WIP".
  • AGENTS.md: Deployment section now describes the uv-based single-stage build.
  • architecture.md: Removed the Dockerfile switch from the "next suggested steps" list.

Testing?

  • docker build -t pyfastapi-test . completes successfully.
  • Container starts and runs migrations:
    INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
    INFO:     Started server process [15]
    INFO:     Application startup complete.
    INFO:     Uvicorn running on http://0.0.0.0:5000
    
  • Application responds to requests on port 5000 inside the container.

Screenshots (optional)

N/A — infrastructure change only.

Anything Else?

  • We initially tried COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv to pull the uv binary directly, but the local Docker daemon returned an auth error from ghcr.io. Falling back to pip install uv inside the image is equally reliable and avoids registry issues.
  • The single-stage tradeoff: if a future dependency requires compilation (e.g., a C extension without wheels), we may need to revert to a multi-stage build or install build-essential in the image. For the current dependency set (FastAPI, SQLAlchemy, Alembic, toolz), all packages provide wheels, so single-stage is safe.

AI Summary (optional)

Migrated the project's Dockerfile from Poetry to uv, replacing a broken multi-stage build (which referenced a non-existent poetry.lock) with a working single-stage build that installs dependencies from uv.lock. Updated README and internal docs to remove outdated Poetry references and reflect the new container workflow.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1177 1158 98% 0% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: b8a91b5 by action🐍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the container build to use uv (the project’s current dependency manager) instead of Poetry, and refreshes documentation to match the new Docker workflow.

Changes:

  • Replaced the Poetry-based multi-stage Docker build with a single-stage uv sync-based build.
  • Updated container run instructions in README.md to use docker by default (with a podman note).
  • Updated AGENTS.md deployment notes to reflect the uv-based Docker build.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
Dockerfile Switches dependency installation and runtime execution to uv in a simplified single-stage image.
README.md Updates container build/run instructions and removes the “WIP” label.
AGENTS.md Updates deployment documentation to describe the new Docker build approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment thread AGENTS.md Outdated
@heinrich10
heinrich10 merged commit b20e838 into main Jun 4, 2026
1 check passed
@heinrich10
heinrich10 deleted the refactor/docker_file branch June 4, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants