ym59 commited on
Commit
4913d55
·
verified ·
1 Parent(s): 6c05537

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -3
Dockerfile CHANGED
@@ -1,7 +1,34 @@
1
  FROM python:3.10-slim
 
 
 
 
 
 
 
 
 
 
2
  WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  COPY . .
4
- RUN pip install flask
5
- RUN pip install gunicorn -r requirements.txt
6
  EXPOSE 7860
7
- CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
 
 
 
1
  FROM python:3.10-slim
2
+
3
+ # Prevent python cache files
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ # HuggingFace model cache location
8
+ ENV HF_HOME=/tmp/hf
9
+ ENV TRANSFORMERS_CACHE=/tmp/hf
10
+ ENV HF_HUB_DISABLE_TELEMETRY=1
11
+
12
  WORKDIR /app
13
+
14
+ # Install system dependencies needed for RDKit / scientific stack
15
+ RUN apt-get update && apt-get install -y \
16
+ build-essential \
17
+ git \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Copy requirements first (improves Docker layer caching)
21
+ COPY requirements.txt .
22
+
23
+ # Install Python dependencies
24
+ RUN pip install --no-cache-dir flask gunicorn \
25
+ && pip install --no-cache-dir -r requirements.txt
26
+
27
+ # Copy application files
28
  COPY . .
29
+
30
+ # HuggingFace Spaces uses port 7860
31
  EXPOSE 7860
32
+
33
+ # --preload loads models once instead of per worker
34
+ CMD ["gunicorn", "--preload", "-w", "1", "-b", "0.0.0.0:7860", "app:app"]