koyu008 commited on
Commit
e0687b0
·
verified ·
1 Parent(s): fe3311f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -6
Dockerfile CHANGED
@@ -1,14 +1,22 @@
1
  FROM python:3.9
2
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- # Set cache dir and create it with proper permissions
6
- ENV TRANSFORMERS_CACHE=/app/.hf_cache
7
- RUN mkdir -p /app/.hf_cache && chmod -R 777 /app/.hf_cache
8
 
9
- COPY requirements.txt requirements.txt
 
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
12
- COPY . .
 
13
 
14
- CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.9
2
 
3
+ # Create user (optional safety layer, not required for HF Spaces)
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+
7
+ # Set working directory
8
  WORKDIR /app
9
 
10
+ # Set Hugging Face Transformers cache path
11
+ ENV TRANSFORMERS_CACHE=/app/hf_cache
12
+ RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
13
 
14
+ # Install dependencies
15
+ COPY --chown=user requirements.txt requirements.txt
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ # Copy the app code
19
+ COPY --chown=user . .
20
 
21
+ # Start the FastAPI app using uvicorn
22
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]