diff --git a/Dockerfile b/Dockerfile_python_fastapi similarity index 95% rename from Dockerfile rename to Dockerfile_python_fastapi index 6f56e4c..5969fc0 100644 --- a/Dockerfile +++ b/Dockerfile_python_fastapi @@ -1,30 +1,30 @@ -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"] +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"]