Skip to content

build(docker): migrate from pip to uv for dependency management#34

Merged
mirrorange merged 2 commits intomirrorange:mainfrom
Huan-zhaojun:pr/feature/dockerfile-uv-migration
Dec 15, 2025
Merged

build(docker): migrate from pip to uv for dependency management#34
mirrorange merged 2 commits intomirrorange:mainfrom
Huan-zhaojun:pr/feature/dockerfile-uv-migration

Conversation

@Huan-zhaojun
Copy link
Contributor

Summary

将 Docker 构建从 pip + requirements.txt 迁移到 uv,统一依赖管理。

动机

项目存在两套依赖管理系统需要手动同步:

  • pyproject.toml + uv.lock 用于本地开发
  • requirements.txt 用于 Docker 构建

历史上曾因遗漏同步导致问题(如 rnet 版本不一致导致 Docker 容器启动失败)。

变更内容

  • Dockerfile: 使用 ghcr.io/astral-sh/uv:python3.11-bookworm-slim 官方镜像
  • 删除 requirements.txt: 依赖管理统一使用 pyproject.toml + uv.lock
  • .dockerignore: 调整以保留 pyproject.tomluv.lock

技术细节

对比项 迁移前 迁移后
基础镜像 python:3.11-slim uv:python3.11-bookworm-slim
依赖安装 pip install -r requirements.txt uv sync --locked
依赖文件 requirements.txt pyproject.toml + uv.lock
Linux 版本 Debian Bookworm Debian Bookworm(一致)

  - Replace pip with uv in Dockerfile using official uv image
  - Remove requirements.txt (no longer needed with uv.lock)
  - Update .dockerignore to include pyproject.toml and uv.lock
  - Add README.md copy step (required by pyproject.toml)

  This eliminates the need to manually sync two dependency systems
  (pyproject.toml + requirements.txt), reducing maintenance burden
  and potential version inconsistencies.

  Base image: ghcr.io/astral-sh/uv:python3.11-bookworm-slim
  pyproject.toml has force-include config for app/static, which requires
  the directory to exist when hatchling builds the project during uv sync
@mirrorange mirrorange merged commit dbb889e into mirrorange:main Dec 15, 2025
1 check passed
@Huan-zhaojun Huan-zhaojun deleted the pr/feature/dockerfile-uv-migration branch December 21, 2025 11:42
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