NickPatel17 commited on
Commit
b3f9b1a
Β·
verified Β·
1 Parent(s): 4856467

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -24
Dockerfile CHANGED
@@ -1,24 +1,25 @@
1
- # ── Hugging Face Spaces Dockerfile ────────────────────────────────────────
2
- # HF Spaces requires port 7860 and a non-root user for security.
3
- FROM python:3.11-slim
4
-
5
- # Create a non-root user (required by HF Spaces)
6
- RUN useradd -m -u 1000 user
7
-
8
- # Set the working directory
9
- WORKDIR /app
10
-
11
- # Copy and install dependencies first (layer caching)
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
-
15
- # Copy the entire backend into the container
16
- COPY . .
17
-
18
- # Switch to non-root user
19
- USER user
20
-
21
- # HF Spaces expects port 7860
22
- EXPOSE 7860
23
-
24
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # Use an official Python runtime
2
+ FROM python:3.11-slim
3
+
4
+ # 1. FORCE PYTHON TO PRINT LOGS IMMEDIATELY (Crucial for debugging!)
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ # Set the working directory
8
+ WORKDIR /app
9
+
10
+ # Copy requirements and install them
11
+ COPY requirements.txt .
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Copy all your backend files into the container
15
+ COPY . .
16
+
17
+ # 2. GRANT FILE PERMISSIONS TO HUGGING FACE (Prevents silent read errors for .pkl files)
18
+ RUN chown -R 1000:1000 /app
19
+ USER 1000
20
+
21
+ # Hugging Face Spaces MUST expose port 7860
22
+ EXPOSE 7860
23
+
24
+ # Command to run your FastAPI server
25
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]