Files
file-templates/Dockerfile
2025-03-29 12:58:09 +00:00

31 lines
746 B
Docker

FROM python:3.12-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# 安装系统依赖
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY pyproject.toml .
# 安装项目依赖
RUN uv pip compile pyproject.toml -o requirements.txt && pip install --no-cache-dir -r requirements.txt
# 复制项目文件
COPY . .
# 暴露端口
EXPOSE 8000
# 启动命令
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000","--workers", "8","--timeout-keep-alive", "30"]