time-series-forecast / Dockerfile
cormort's picture
Update Dockerfile
8e38231 verified
raw
history blame contribute delete
874 Bytes
# 使用官方 Python 3.10 基礎映像檔
FROM python:3.10
# 設定工作目錄
WORKDIR /code
# ⚠️ 關鍵新增:先獨立安裝 CPU 版本的 PyTorch,節省超多空間與建置時間
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# 複製 requirements.txt 並安裝其他依賴
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# 設定 Hugging Face 緩存目錄權限 (避免下載模型時發生權限報錯)
ENV HF_HOME=/tmp/huggingface
RUN mkdir -p /tmp/huggingface && chmod 777 /tmp/huggingface
# 複製專案代碼 (包含 app.py 和 static 資料夾)
COPY . /code
# 開放 port 7860 (Hugging Face Spaces 的預設 port)
EXPOSE 7860
# 啟動 FastAPI 伺服器
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]