Jethro85 commited on
Commit
6908e60
·
1 Parent(s): a012047

Spaces: switch to Python 3.10 and preinstall PyYAML/Cython

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -17
Dockerfile CHANGED
@@ -1,30 +1,27 @@
1
- # ---- Base image ----
2
- FROM python:3.11-slim
3
 
4
- # ---- System setup (add OS libs your deps may need) ----
5
- # Add or remove packages as needed. Keep it small to speed builds.
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  build-essential \
8
- && rm -rf /var/lib/apt/lists/*
9
 
10
- # ---- App files ----
11
  WORKDIR /app
12
- # Copy only requirements first to leverage Docker layer caching
 
 
 
 
 
13
  COPY requirements.txt /app/requirements.txt
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Now copy the rest of your code
17
  COPY . /app
18
 
19
- # ---- Runtime env ----
20
- # HF Spaces provides a PORT env var; default to 7860 for local runs
21
- ENV PORT=7860
22
- ENV PYTHONUNBUFFERED=1
23
-
24
- # Make sure Flask binds publicly; gunicorn will use $PORT
25
  EXPOSE 7860
26
 
27
- # ---- Start command ----
28
- # Gunicorn will import your Flask app named "app" from run.py
29
- # If your app variable has a different name, change run:app accordingly.
30
  CMD ["gunicorn", "run:app", "--workers", "2", "--threads", "8", "--timeout", "120", "--bind", "0.0.0.0:${PORT}"]
 
 
1
+ # Dockerfile
2
+ FROM python:3.10-slim
3
 
4
+ # Build tools
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  build-essential \
7
+ && rm -rf /var/lib/apt/lists/*
8
 
 
9
  WORKDIR /app
10
+
11
+ # Upgrade pip toolchain and preinstall deps that unblock tf-models-official
12
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
13
+ && pip install --no-cache-dir "Cython<3" "pyyaml<5.4.0,>=5.1"
14
+
15
+ # Then install your requirements
16
  COPY requirements.txt /app/requirements.txt
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # App code
20
  COPY . /app
21
 
22
+ ENV PORT=7860 PYTHONUNBUFFERED=1
 
 
 
 
 
23
  EXPOSE 7860
24
 
25
+ # Gunicorn loads Flask app from run.py
 
 
26
  CMD ["gunicorn", "run:app", "--workers", "2", "--threads", "8", "--timeout", "120", "--bind", "0.0.0.0:${PORT}"]
27
+