# 使用Python 3.11作为基础镜像 FROM python:3.11-slim # 设置工作目录 WORKDIR /app # 设置环境变量 ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 # 安装系统依赖 RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* # 克隆代码仓库 RUN git clone https://github.com/yangjianchuan/PySQLAPI /app # 安装Python依赖 RUN pip install --no-cache-dir -r requirements.txt # 暴露端口 EXPOSE 8000 # 启动命令 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]