123456789101112131415161718192021222324252627282930313233 |
- # 使用轻量级 Python 基础镜像
- FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/python:3.11-slim
- # 设置工作目录
- WORKDIR /app
- # 环境变量优化
- ENV PYTHONDONTWRITEBYTECODE=1 \
- PYTHONUNBUFFERED=1 \
- PIP_DISABLE_PIP_VERSION_CHECK=on \
- TZ=Asia/Shanghai \
- PATH="/root/.local/bin:$PATH" \
- DEBIAN_FRONTEND=noninteractive
- # 安装系统依赖(如果 requirements 里需要编译 C 扩展)
- RUN apt-get update && apt-get install -y --no-install-recommends \
- build-essential \
- curl \
- tzdata \
- && rm -rf /var/lib/apt/lists/*
- # 先复制 requirements 并安装依赖(利用缓存)
- COPY requirements.txt .
- RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
- # 再复制项目文件
- COPY . .
- # 暴露端口
- EXPOSE 8001, 8002
- # 启动命令
- CMD ["hypercorn", "vector_app:app", "--config", "config.toml"]
|