songrecommend / Dockerfile
Forawish's picture
Create Dockerfile
9828dd6 verified
Raw
History Blame Contribute Delete
608 Bytes
# 1. 使用官方的 Python 輕量版作為基底
FROM python:3.9-slim
# 2. 設定容器內的工作目錄
WORKDIR /code
# 3. 複製 requirements.txt 並安裝 Python 套件
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# 4. 複製專案內的所有檔案(包含 app.py, html 與 csv)到容器中
COPY . .
# 5. 暴露出 Hugging Face 預設的 7860 連接埠
EXPOSE 7860
# 6. 開機指令:啟動 uvicorn,並將監聽埠強制綁定在 7860,Host 設為 0.0.0.0
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]