opex792 commited on
Commit
d049016
·
verified ·
1 Parent(s): 41c33fc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +2 -18
Dockerfile CHANGED
@@ -1,42 +1,26 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.10-slim
3
 
4
- # Set the working directory in the container
5
  WORKDIR /code
6
 
7
- # Install system dependencies
8
- # - ffmpeg is required by librosa/transformers for MP3 and other formats
9
- # - git is needed sometimes by transformers to download models/tokenizers
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
  ffmpeg \
12
  git \
13
  && apt-get clean \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Set Hugging Face cache directory to a writable location inside the workdir
17
- # This prevents permission errors when writing to /.cache
18
  ENV HF_HOME=/code/.cache
19
  ENV HF_HUB_CACHE=/code/.cache/hub
20
- ENV TRANSFORMERS_CACHE=/code/.cache/hub # Often transformers uses HF_HUB_CACHE
21
- # Create the cache directory
22
- # The user running the python process will own /code, so it should have write access
23
  RUN mkdir -p $HF_HUB_CACHE
24
 
25
- # Copy the requirements file into the container
26
  COPY ./requirements.txt /code/requirements.txt
27
 
28
- # Install Python dependencies
29
- # --no-cache-dir reduces image size
30
  RUN pip install --no-cache-dir --upgrade pip && \
31
  pip install --no-cache-dir -r requirements.txt
32
 
33
- # Copy the application code into the container
34
  COPY ./app.py /code/app.py
35
 
36
- # Expose the port the app runs on (Hugging Face Spaces default is 7860)
37
  EXPOSE 7860
38
 
39
- # Define the command to run the application
40
- # Use 0.0.0.0 to make it accessible from outside the container
41
- # Use port 7860 for HF Spaces
42
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.10-slim
2
 
 
3
  WORKDIR /code
4
 
 
 
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  ffmpeg \
7
  git \
8
  && apt-get clean \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
 
11
  ENV HF_HOME=/code/.cache
12
  ENV HF_HUB_CACHE=/code/.cache/hub
13
+ ENV TRANSFORMERS_CACHE=/code/.cache/hub
14
+
 
15
  RUN mkdir -p $HF_HUB_CACHE
16
 
 
17
  COPY ./requirements.txt /code/requirements.txt
18
 
 
 
19
  RUN pip install --no-cache-dir --upgrade pip && \
20
  pip install --no-cache-dir -r requirements.txt
21
 
 
22
  COPY ./app.py /code/app.py
23
 
 
24
  EXPOSE 7860
25
 
 
 
 
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]