dockerfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 sed -i 's|deb.debian.org|mirrors.ustc.edu.cn|g' /etc/apt/sources.list.d/debian.sources && \
  13. apt-get update && \
  14. apt-get install -y --no-install-recommends \
  15. libglib2.0-0 \
  16. libsm6 \
  17. libxext6 \
  18. libxrender-dev \
  19. libgomp1 \
  20. libgthread-2.0-0 \
  21. libgtk-3-0 \
  22. libgstreamer1.0-0 \
  23. libgstreamer-plugins-base1.0-0 \
  24. ffmpeg \
  25. ca-certificates \
  26. && rm -rf /var/lib/apt/lists/*
  27. # ========== 配置pip源(国内加速) ==========
  28. RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
  29. pip config set global.trusted-host mirrors.aliyun.com
  30. # ========== 安装Python依赖(包括所有系统库的Python包装) ==========
  31. COPY requirements.txt .
  32. RUN pip install --no-cache-dir -r requirements.txt
  33. # ========== 复制应用代码 ==========
  34. COPY . .
  35. # ========== 暴露端口 ==========
  36. EXPOSE 8000
  37. # ========== 启动应用 ==========
  38. CMD ["python", "-m", "uvicorn", "parse_service:app", "--host", "0.0.0.0", "--port", "8000"]