File size: 931 Bytes
b125668
55e1701
 
 
 
 
72f5bfa
b125668
 
72f5bfa
55e1701
85d63c1
d67c73d
72f5bfa
55e1701
1f42eea
 
 
 
55e1701
1f42eea
d2006b6
9b8469c
55e1701
 
 
 
 
 
2a41314
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
FROM nvcr.io/nvidia/pytorch:25.09-py3

# 安装额外依赖(如果基础镜像已包含部分依赖,pip 会自动跳过)
RUN pip install --no-cache-dir \
    fastapi \
    uvicorn[standard] \
    mbridge==0.13.1 \
    termcolor \
    transformers==4.57.0

# 添加 Megatron-LM core_v0.12.2
RUN git clone -b core_v0.13.0rc4 --depth 1 https://github.com/NVIDIA/Megatron-LM.git /opt/Megatron-LM

# RUN git clone -b main --depth 1 https://github.com/ISEEKYAN/mbridge.git /opt/mbridge 

# 创建与 HF Spaces 运行时一致的 uid=1000 用户,避免 getpwuid() 错误
RUN groupadd -g 1000 user && \
    useradd -m -u 1000 -g user user || true

# 复制代码至工作目录
WORKDIR $HOME/app
COPY --chown=user . $HOME/app

# HF Spaces 默认通过 $PORT 注入端口
ENV PYTHONPATH=/opt/Megatron-LM:$PYTHONPATH
ENV PORT=7860
EXPOSE 7860

# 启动 FastAPI 服务
CMD ["bash", "-c", "uvicorn app:app --host 0.0.0.0 --port $PORT"]