ladyzoe's picture
Update Dockerfile
db803f8 verified
# Dockerfile (這是你的 Hugging Face Space 將使用的 Docker 配置)
# 使用 Python 3.9 的輕量級基礎映像
FROM python:3.9-slim-buster
# 安裝 OpenCV 所需的系統依賴
# 這會安裝 libGL.so.1, libgthread-2.0.so.0 和其他相關庫
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libxext6 \
libsm6 \
libxrender1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# 設定工作目錄為 /app
WORKDIR /app
# 複製 requirements.txt 並安裝所有 Python 依賴
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 複製所有應用程式檔案到容器中 (包括 app.py 和 best.pt)
COPY . .
# 暴露應用程式將運行的埠
EXPOSE 7860
# 定義容器啟動時執行的命令
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]