Rizwan9 commited on
Commit
5e9c81f
·
verified ·
1 Parent(s): ed17c28

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -11
Dockerfile CHANGED
@@ -1,17 +1,29 @@
1
- # Use official Python image
2
- FROM python:3.10-slim
3
 
4
- # Set working directory
 
 
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy files to the container
8
- COPY . /app
 
 
9
 
10
- # Install dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Expose port (Hugging Face expects 7860, but Flask uses 5000 — both fine)
14
- EXPOSE 5000
 
 
15
 
16
- # Run the app with gunicorn
17
- CMD ["gunicorn", "--workers", "2", "--threads", "2", "--timeout", "120", "--bind", "0.0.0.0:5000", "app:app"]
 
 
1
+ # ---- Base image ----
2
+ FROM python:3.11-slim
3
 
4
+ # ---- System deps (for numpy/scipy/sklearn) ----
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ build-essential \
7
+ libatlas-base-dev \
8
+ gfortran \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # ---- Workdir ----
12
  WORKDIR /app
13
 
14
+ # ---- Install Python deps first (better caching) ----
15
+ COPY requirements.txt /app/
16
+ RUN pip install --no-cache-dir --upgrade pip \
17
+ && pip install --no-cache-dir -r requirements.txt
18
 
19
+ # ---- App code ----
20
+ COPY . /app
21
 
22
+ # ---- Port configuration ----
23
+ # Hugging Face sets $PORT for you; default to 7860 for local dev
24
+ ENV PORT=7860
25
+ EXPOSE 7860
26
 
27
+ # ---- Start server (bind to $PORT) ----
28
+ # 1 worker + 2 threads is enough for CPU Spaces; adjust if needed
29
+ CMD ["bash", "-lc", "gunicorn app:app --bind 0.0.0.0:${PORT} --workers 1 --threads 2 --timeout 120 --log-level info"]