Grinding commited on
Commit
c1c0671
·
verified ·
1 Parent(s): 7edcca4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -8
Dockerfile CHANGED
@@ -2,23 +2,33 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /code
4
 
 
 
 
5
  # Copy requirements
6
  COPY ./requirements.txt /code/requirements.txt
7
 
8
- # Install system deps for ffmpeg + audio libs
9
- RUN apt-get update && apt-get install -y ffmpeg libsndfile1 && rm -rf /var/lib/apt/lists/*
10
-
11
- # Install Python deps
12
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
 
14
- # Use HF_HOME to control cache location
 
 
 
 
 
15
  ENV HF_HOME=/code/hf_cache
16
- RUN mkdir -p /code/hf_cache && chmod -R 777 /code/hf_cache
17
 
18
- # Pre-download ASR model at build time
 
 
 
19
  RUN python -c "from faster_whisper import download_model; download_model('distil-whisper/distil-large-v3')"
20
 
21
- COPY ./app.py /code/app.py
 
22
 
23
  EXPOSE 7860
 
 
24
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
2
 
3
  WORKDIR /code
4
 
5
+ # Install system dependencies for ffmpeg and audio libs
6
+ RUN apt-get update && apt-get install -y ffmpeg libsndfile1 && rm -rf /var/lib/apt/lists/*
7
+
8
  # Copy requirements
9
  COPY ./requirements.txt /code/requirements.txt
10
 
11
+ # Install Python dependencies
 
 
 
12
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
13
 
14
+ # Create a non-root user and set permissions
15
+ RUN useradd -m -u 1000 appuser && \
16
+ mkdir -p /code/hf_cache && \
17
+ chown -R appuser:appuser /code/hf_cache
18
+
19
+ # Set environment variable for Hugging Face cache
20
  ENV HF_HOME=/code/hf_cache
 
21
 
22
+ # Switch to non-root user
23
+ USER appuser
24
+
25
+ # Pre-download and convert the ASR model to CTranslate2 format
26
  RUN python -c "from faster_whisper import download_model; download_model('distil-whisper/distil-large-v3')"
27
 
28
+ # Copy application code
29
+ COPY --chown=appuser:appuser ./app.py /code/app.py
30
 
31
  EXPOSE 7860
32
+
33
+ # Run as non-root user
34
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]