dockerfile 1.2 KB

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