Using uv in Docker
ghcr.io/astral-sh/uv
Getting started
Sync the project into a new environment, using the frozen lockfile
It is best practice to add .venv to a .dockerignore file in your repository to prevent it from being included in image builds.
Developing in a container
積ん読
Optimizations
Compiling bytecode
Caching
RUN --mount=type=cache,target=/root/.cache/uv
Intermediate layers
続く例のように2段にする(依存のインストール -> プロジェクトのインストール)
Non-editable installs
uv sync --no-editable (0.4.11~)
Using uv temporarily
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv uv sync
Using the pip interface
uvプロジェクトは2段で入れるように案内
Copy from the cache instead of linking since it's a mounted volume
コメントの通り、即時copyしてしまうのがよい
Install the project's dependencies using the lockfile and settings
uv sync --frozen --no-install-project --no-dev
Then, add the rest of the project source code and install it
uv sync --frozen --no-dev
=ライブラリのeditable install
PATHに.venvを追加
ghcr.io/astral-sh/uvのENTRYPOINTを[]で上書き
Reset the entrypoint, don't invoke uv