Dockerfile 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. # 使用本地已有的沐曦 maca + PyTorch 2.8 + Python 3.10 镜像
  2. # 驱动版本 maca 3.5.3.502,PyTorch 2.8,兼容性好
  3. FROM cr.metax-tech.com/public-ai-release/maca/vllm-metax:0.19.0-maca.ai3.5.3.502-torch2.8-py310-ubuntu22.04-amd64
  4. WORKDIR /app
  5. # 设置 conda Python 路径(镜像使用 /opt/conda)
  6. ENV PATH="/opt/conda/bin:$PATH"
  7. RUN apt-get update && apt-get install -y git openssh-client sshpass && rm -rf /var/lib/apt/lists/*
  8. # 升级 pip
  9. RUN /opt/conda/bin/pip install --no-cache-dir --upgrade pip
  10. # 复制依赖文件并安装(跳过 torch,镜像已自带)
  11. COPY requirements.txt .
  12. RUN /opt/conda/bin/pip install --no-cache-dir -r requirements.txt
  13. # 复制应用代码
  14. COPY . .
  15. # 沐曦 maca 环境变量(镜像中通常已设置,这里显式声明)
  16. ENV MACA_PATH=/opt/maca
  17. ENV LD_LIBRARY_PATH=/opt/maca/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/ompi/lib:${LD_LIBRARY_PATH}
  18. ENV MACA_CLANG_PATH=/opt/maca/mxgpu_llvm/bin
  19. EXPOSE 8010
  20. HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
  21. CMD /opt/conda/bin/python -c "import urllib.request; urllib.request.urlopen('http://localhost:8010/health')" || exit 1
  22. CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8010"]