Spaces:
Sleeping
Sleeping
File size: 702 Bytes
f4286ee f0cae54 f4286ee |
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 |
# 使用官方的 Python 映像
FROM python:3.10-slim
# 設置工作目錄
WORKDIR /app
# 複製 requirements.txt 並安裝 Python 依賴
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 複製應用程式碼到容器內
COPY . .
# 設置 transformers cache 目錄
ENV TRANSFORMERS_CACHE=/app/cache
# 預先下載模型
RUN python -c "from transformers import AutoTokenizer, AutoModel; AutoTokenizer.from_pretrained('intfloat/multilingual-e5-large'); AutoModel.from_pretrained('intfloat/multilingual-e5-large')"
# 創建 cache 目錄
RUN mkdir -p /app/cache
# 暴露端口
EXPOSE 7860
# 運行應用
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|