Skip to content

Commit 86c51d4

Browse files
committed
Dockerfile modify
1 parent fde1460 commit 86c51d4

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 官方 uv + Python 3.12 基础镜像
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
3+
4+
ENV PYTHONUNBUFFERED=1 \
5+
PYTHONDONTWRITEBYTECODE=1
6+
7+
WORKDIR /app
8+
9+
# 先只拷贝依赖文件,加快缓存命中
10+
COPY pyproject.toml uv.lock ./
11+
12+
# 根据 uv.lock 安装依赖(只装运行时依赖)
13+
RUN uv sync --frozen --no-dev
14+
15+
# 再拷贝项目代码
16+
COPY . .
17+
18+
# 使用项目虚拟环境中的 Python/包
19+
ENV PATH="/app/.venv/bin:${PATH}"
20+
21+
# 暴露 FastAPI 端口
22+
EXPOSE 8080
23+
24+
# 默认启动 FastAPI
25+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

0 commit comments

Comments
 (0)