dockerfile 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # 基础镜像:使用Python官方镜像(更稳定)
  2. FROM python:3.11-slim
  3. # 设置工作目录
  4. WORKDIR /app
  5. # 环境变量
  6. ENV PYTHONIOENCODING=utf-8 \
  7. PIP_DEFAULT_TIMEOUT=120 \
  8. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  9. DEBIAN_FRONTEND=noninteractive \
  10. PYTHONUNBUFFERED=1
  11. # ========== 系统依赖安装 ==========
  12. RUN apt-get update && \
  13. apt-get install -y --no-install-recommends \
  14. ca-certificates \
  15. && rm -rf /var/lib/apt/lists/*
  16. # ========== 配置pip源(国内加速) ==========
  17. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
  18. pip config set global.trusted-host mirrors.aliyun.com
  19. # ========== 安装Python依赖(包括所有系统库的Python包装) ==========
  20. COPY requirements.txt .
  21. RUN pip install --no-cache-dir -r requirements.txt
  22. # ========== 复制应用代码 ==========
  23. COPY . .
  24. # ========== 暴露端口 ==========
  25. EXPOSE 8000
  26. # ========== 启动应用 ==========
  27. CMD ["python", "-m", "uvicorn", "parse_service:app", "--host", "0.0.0.0", "--port", "8000"]