27 lines
838 B
Docker
27 lines
838 B
Docker
FROM continuumio/miniconda3:latest
|
|
|
|
WORKDIR /app
|
|
|
|
# 安装 Python 3.12 和 pymetis (通过 conda-forge 避免编译问题)
|
|
RUN conda install -y -c conda-forge python=3.12 pymetis && \
|
|
conda clean -afy
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# 本地数据目录和环境变量在运行时通过 Compose 挂载或注入,
|
|
# 不应进入镜像构建上下文。
|
|
RUN mkdir -p /app/db_inp /app/inp /app/data /app/temp
|
|
|
|
COPY app ./app
|
|
|
|
# 设置 PYTHONPATH 以便 uvicorn 找到 app 模块
|
|
ENV PYTHONPATH=/app
|
|
|
|
EXPOSE 8000
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=30s --retries=6 \
|
|
CMD python -c "from urllib.request import urlopen; urlopen('http://127.0.0.1:8000/health', timeout=2)" || exit 1
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]
|