mutarisi commited on
Commit
03c69ab
·
1 Parent(s): 5a1ee4b
Files changed (1) hide show
  1. Dockerfile +16 -8
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # 1. Base Image Declaration (Corrected 'slim' tag)
2
  FROM python:3.11-slim
3
 
4
  # 2. Environment Variables & Cleanup
@@ -11,12 +11,19 @@ ENV CUDA_VISIBLE_DEVICES=""
11
  # Ensure Python output is immediately available in logs
12
  ENV PYTHONUNBUFFERED True
13
 
14
- # Set the port required by Hugging Face Spaces/Uvicorn
15
- ENV PORT 7862
 
 
 
 
 
 
16
 
17
  # 3. System Dependencies (Required by OpenCV/cv2)
 
18
  RUN apt-get update && \
19
- apt-get install -y libgl1 libglib2.0-0 libsm6 libxext6 && \
20
  rm -rf /var/lib/apt/lists/*
21
 
22
  # 4. Working Directory
@@ -29,9 +36,10 @@ RUN pip install --no-cache-dir -r requirements.txt
29
  # 6. Application Code
30
  COPY . .
31
 
32
- # 7. Port Documentation (EXPOSE is optional but good practice)
33
- EXPOSE 7860
34
 
35
  # 8. Define the command to start the Uvicorn server
36
- # This runs the 'app' object in the 'app.py' module, listening on port 7860.
37
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7862"]
 
 
1
+ # 1. Base Image Declaration (Use the correct slim tag)
2
  FROM python:3.11-slim
3
 
4
  # 2. Environment Variables & Cleanup
 
11
  # Ensure Python output is immediately available in logs
12
  ENV PYTHONUNBUFFERED True
13
 
14
+ # CRITICAL: Set the port required by Hugging Face Spaces/Uvicorn
15
+ # Spaces typically inject a PORT variable, but setting a default is good.
16
+ ENV PORT 7862
17
+
18
+ # Optional: Add the custom HuggingFace cache paths used in apiRoutes.py
19
+ # This is often unnecessary in Spaces, but ensures compatibility with your code.
20
+ ENV HF_HOME /tmp
21
+ ENV HUGGINGFACE_HUB_CACHE /tmp/huggingface_cache
22
 
23
  # 3. System Dependencies (Required by OpenCV/cv2)
24
+ # Added a missing system dependency often needed for OpenCV in headless environments
25
  RUN apt-get update && \
26
+ apt-get install -y libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 && \
27
  rm -rf /var/lib/apt/lists/*
28
 
29
  # 4. Working Directory
 
36
  # 6. Application Code
37
  COPY . .
38
 
39
+ # 7. Port Documentation (Optional, but use the correct port)
40
+ EXPOSE 7862
41
 
42
  # 8. Define the command to start the Uvicorn server
43
+ # CRITICAL: Ensure the port matches the ENV PORT variable (7862).
44
+ # This runs the 'app' object in the 'app.py' module, listening on port 7862.
45
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7862"]