mutarisi commited on
Commit
fc081b5
·
1 Parent(s): 10fc241

docker file

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1. Base Image Declaration (Corrected 'slim' tag)
2
+ FROM python:3.11-slim
3
+
4
+ # 2. Environment Variables & Cleanup
5
+ # Suppress Matplotlib cache permission warning
6
+ ENV MPLCONFIGDIR /tmp/.matplotlib
7
+
8
+ # Explicitly force CPU and suppress CUDA warnings (if not using a GPU space)
9
+ ENV CUDA_VISIBLE_DEVICES=""
10
+
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
23
+ WORKDIR /app
24
+
25
+ # 5. Dependency Installation (Leverages Docker caching)
26
+ COPY requirements.txt .
27
+ RUN pip install --no-cache-dir -r requirements.txt
28
+
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"]