Spaces:
Runtime error
Runtime error
FROM ubuntu:22.04 AS stage1 | |
# 安装 Python 3.10 | |
RUN apt-get update && \ | |
apt-get install -y python3.10 python3-pip | |
# 设置 python 和 pip 的替代版本 | |
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 && \ | |
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | |
# 安裝 Python 相關依賴 | |
RUN pip install --no-cache-dir pip==22.3.1 && \ | |
pip install --no-cache-dir \ | |
datasets \ | |
"huggingface-hub>=0.19" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0" | |
# 安裝系統級別的依賴 | |
RUN apt-get install -y \ | |
git \ | |
git-lfs \ | |
ffmpeg \ | |
libsm6 \ | |
libxext6 \ | |
cmake \ | |
libgl1-mesa-glx \ | |
&& git lfs install \ | |
&& rm -rf /var/lib/apt/lists/* | |
FROM stage1 AS stage2 | |
# 修改 apt-get 以使用 fakeroot,並創建非 root 用戶 | |
RUN apt-get update && apt-get install -y fakeroot && \ | |
mv /usr/bin/apt-get /usr/bin/.apt-get && \ | |
echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \ | |
chmod +x /usr/bin/apt-get && \ | |
rm -rf /var/lib/apt/lists/* && \ | |
useradd -m -u 1000 user | |
# 安裝 requirements.txt 中的依賴 | |
COPY requirements.txt requirements.txt | |
RUN pip install --no-cache-dir -r requirements.txt | |
FROM stage2 AS stage3 | |
# 安裝 Gradio 及相關依賴 | |
RUN pip install --no-cache-dir \ | |
gradio[oauth]==4.27.0 \ | |
"uvicorn>=0.14.0" | |
FROM stage3 AS stage4 | |
WORKDIR /home/user/app | |
COPY --chown=1000:1000 . /home/user/app | |
ENTRYPOINT ["python", "app.py"] |