Somalitts commited on
Commit
a0048e9
·
verified ·
1 Parent(s): 9543ae5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -6
Dockerfile CHANGED
@@ -1,15 +1,24 @@
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
- # Prevent permission errors with HuggingFace cache
6
- ENV TRANSFORMERS_CACHE=/tmp/hf-cache
 
7
 
8
- COPY requirements.txt .
9
- RUN apt-get update && apt-get install -y ffmpeg && pip install --no-cache-dir -r requirements.txt
10
 
11
- COPY app.py .
 
 
12
 
 
 
 
 
13
  EXPOSE 7860
14
 
15
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Set the working directory
4
  WORKDIR /app
5
 
6
+ # Create a non-root user and switch to it
7
+ RUN useradd -m appuser
8
+ USER appuser
9
 
10
+ # Set the Hugging Face home directory to a user-owned path
11
+ ENV HF_HOME=/home/appuser/.cache/huggingface
12
 
13
+ # Copy the requirements file and install dependencies
14
+ COPY --chown=appuser:appuser requirements.txt .
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # Copy the application code
18
+ COPY --chown=appuser:appuser app.py .
19
+
20
+ # Expose the port
21
  EXPOSE 7860
22
 
23
+ # Set the default command to run the application
24
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]