1234567891011121314151617181920212223242526272829303132333435 |
- # 使用轻量级 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"
- # 安装系统依赖(构建 wheel、时区等)
- RUN apt-get update && apt-get install -y --no-install-recommends \
- build-essential \
- curl \
- tzdata \
- && rm -rf /var/lib/apt/lists/*
- # 设置时区
- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
- # 复制 requirements 并安装依赖
- COPY requirements.txt .
- RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
- # 复制项目文件
- COPY . .
- # 暴露端口
- EXPOSE 8001
- # 启动命令
- CMD ["hypercorn", "vector_app:app", "--config", "config.toml"]
|