Aman Githala commited on
Commit
c5fbcdb
·
1 Parent(s): dcd9854

Update Dockerfile for Hugging Face Spaces

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -4
Dockerfile CHANGED
@@ -19,13 +19,22 @@ COPY requirements.txt .
19
  # Added default-timeout to prevent "ReadTimeoutError" on slow connections
20
  RUN pip install --default-timeout=1000 --no-cache-dir -r requirements.txt
21
 
 
 
 
22
  # 6. Copy the rest of your code
23
- COPY . .
24
 
25
  # 7. Run the seed script to "bake" the AI models into the image
 
 
 
 
 
26
  RUN python seed_references.py
27
 
28
  # 8. Start the app (The Critical Fix)
29
- # We use "sh -c" so we can read the ${PORT} variable from Render.
30
- # If Render gives a port (usually 10000), we use it. If not, we use 8000.
31
- CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
 
19
  # Added default-timeout to prevent "ReadTimeoutError" on slow connections
20
  RUN pip install --default-timeout=1000 --no-cache-dir -r requirements.txt
21
 
22
+ # 5b. HF SPACES: Create a non-root user
23
+ RUN useradd -m -u 1000 user
24
+
25
  # 6. Copy the rest of your code
26
+ COPY --chown=user . .
27
 
28
  # 7. Run the seed script to "bake" the AI models into the image
29
+ # We run as root first to ensure permissions, or we can run as user if pip installed locally.
30
+ # However, usually pip installs are global here. Let's switch to user.
31
+ USER user
32
+
33
+ # Pre-load/Seed models (as user 1000 to avoid permission issues)
34
  RUN python seed_references.py
35
 
36
  # 8. Start the app (The Critical Fix)
37
+ # We use "sh -c" so we can read the ${PORT} variable from Render/HF.
38
+ # Spaces uses 7860 by default.
39
+ ENV PORT=7860
40
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]