William941008 commited on
Commit
efe9eec
·
verified ·
1 Parent(s): d6e1be5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -2
Dockerfile CHANGED
@@ -2,11 +2,26 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  COPY requirements.txt .
6
  RUN pip install --no-cache-dir -r requirements.txt
7
  RUN pip install --no-cache-dir huggingface_hub
8
 
9
  COPY . .
10
 
11
- # 启动时再下载模型,绝对不报错
12
- CMD python -c "from huggingface_hub import snapshot_download; import os; snapshot_download(repo_id='William941008/air-quality-model', local_dir='./models', token=os.getenv('AirPollutionToken'))" && uvicorn main:app --host 0.0.0.0 --port 7860
 
2
 
3
  WORKDIR /app
4
 
5
+ # 安装 opencv 必需的系统依赖(修复你现在的错误)
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ libgl1-mesa-glx \
8
+ libglib2.0-0 \
9
+ libxcb-randr0 \
10
+ libxcb-image0 \
11
+ libxcb-xfixes0 \
12
+ libxcb-shm0 \
13
+ libxcb-render0 \
14
+ libxcb-icccm4 \
15
+ libxcb-sync1 \
16
+ libxcb-shape0 \
17
+ libxcb-keyboard1 \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
  COPY requirements.txt .
21
  RUN pip install --no-cache-dir -r requirements.txt
22
  RUN pip install --no-cache-dir huggingface_hub
23
 
24
  COPY . .
25
 
26
+ # 启动项目(模型下载 + 运行)
27
+ CMD python -c "from huggingface_hub import snapshot_download;import os;snapshot_download(repo_id='William941008/air-quality-model',local_dir='./models',token=os.getenv('AirPollutionToken'))" && uvicorn main:app --host 0.0.0.0 --port 7860