| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- # 基础镜像:使用Python官方镜像(更稳定)
- FROM python:3.11-slim
- # 设置工作目录
- WORKDIR /app
- # 环境变量
- ENV PYTHONIOENCODING=utf-8 \
- PIP_DEFAULT_TIMEOUT=120 \
- PIP_DISABLE_PIP_VERSION_CHECK=1 \
- DEBIAN_FRONTEND=noninteractive \
- PYTHONUNBUFFERED=1
- # ========== 系统依赖安装 ==========
- RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- libglib2.0-0 \
- libsm6 \
- libxext6 \
- libxrender-dev \
- libgomp1 \
- libgthread-2.0-0 \
- libgtk-3-0 \
- libgstreamer1.0-0 \
- libgstreamer-plugins-base1.0-0 \
- ffmpeg \
- ca-certificates \
- && rm -rf /var/lib/apt/lists/*
- # ========== 配置pip源(国内加速) ==========
- RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
- pip config set global.trusted-host mirrors.aliyun.com
- # ========== 安装Python依赖(包括所有系统库的Python包装) ==========
- COPY requirements.txt .
- RUN pip install --no-cache-dir -r requirements.txt
- # ========== 复制应用代码 ==========
- COPY . .
- # ========== 暴露端口 ==========
- EXPOSE 8000
- # ========== 启动应用 ==========
- CMD ["python", "-m", "uvicorn", "parse_service:app", "--host", "0.0.0.0", "--port", "8000"]
|