bla commited on
Commit
b3f1b81
·
verified ·
1 Parent(s): e3d0b72

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -5
Dockerfile CHANGED
@@ -22,16 +22,22 @@ COPY . .
22
  # Expose the FastAPI port
23
  EXPOSE 7860
24
 
 
25
  ENV PYTHONDONTWRITEBYTECODE=1 \
26
  PYTHONUNBUFFERED=1 \
27
- XDG_CACHE_HOME=/app/.cache
28
- # Create non-root user
29
- RUN mkdir -p /app/.cache /app/.local && \
30
- chown -R root:root /app && \
 
 
 
 
 
31
  chmod -R 777 /app
32
 
33
  RUN pip install spacy && python -m spacy download en_core_web_sm
34
- USER root
35
 
36
  # Start the FastAPI app
37
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
22
  # Expose the FastAPI port
23
  EXPOSE 7860
24
 
25
+ # Environment variables to control Python and caching behavior.
26
  ENV PYTHONDONTWRITEBYTECODE=1 \
27
  PYTHONUNBUFFERED=1 \
28
+ XDG_CACHE_HOME=/app/.cache \
29
+ HF_HOME=/app/.cache/huggingface \
30
+ PIP_ROOT_USER_ACTION=ignore
31
+
32
+ # Create a non-root user and set up directories with wide permissions.
33
+ RUN adduser --disabled-password --gecos '' appuser && \
34
+ mkdir -p /app/.cache/huggingface/hub && \
35
+ mkdir -p /app/.local && \
36
+ chown -R appuser:appuser /app && \
37
  chmod -R 777 /app
38
 
39
  RUN pip install spacy && python -m spacy download en_core_web_sm
40
+ USER appuser
41
 
42
  # Start the FastAPI app
43
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]