Athspi commited on
Commit
474728b
·
verified ·
1 Parent(s): 6ab4ced

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -3
Dockerfile CHANGED
@@ -1,11 +1,51 @@
 
 
1
  FROM python:3.10
2
 
 
3
  WORKDIR /app
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  COPY requirements.txt .
6
- RUN pip install --no-cache-dir -r requirements.txt
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  COPY app.py .
9
 
10
- EXPOSE 7860
11
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
1
+ # ----------- START Dockerfile -----------
2
+ # Use an official Python runtime as a parent image
3
  FROM python:3.10
4
 
5
+ # Set the working directory in the container
6
  WORKDIR /app
7
 
8
+ # Set environment variables
9
+ # - PYTHONUNBUFFERED: Ensures Python output is sent straight to terminal without buffering
10
+ # - HF_HOME: Specifies where Hugging Face models/datasets should be cached INSIDE the container
11
+ ENV PYTHONUNBUFFERED=1 \
12
+ HF_HOME=/app/hf_cache
13
+
14
+ # Install system dependencies
15
+ # - ffmpeg: Required by pydub
16
+ # - build-essential: May be needed for compiling some Python dependencies
17
+ # - git: Sometimes needed if pip installs from git repositories
18
+ RUN apt-get update && apt-get install -y --no-install-recommends \
19
+ ffmpeg \
20
+ build-essential \
21
+ git \
22
+ && apt-get clean \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Copy the requirements file into the container
26
  COPY requirements.txt .
 
27
 
28
+ # Install Python dependencies
29
+ # Upgrade pip first, use --no-cache-dir to reduce image size
30
+ RUN pip install --no-cache-dir --upgrade pip && \
31
+ pip install --no-cache-dir -r requirements.txt
32
+
33
+ # Copy the model download script BEFORE the main app code
34
+ COPY download_models.py .
35
+
36
+ # Run the model download script during the build process
37
+ # This downloads models into the HF_HOME directory defined above
38
+ # NOTE: This step can take a LONG time and requires network access during build
39
+ RUN python download_models.py
40
+
41
+ # Copy the rest of the application code into the container
42
  COPY app.py .
43
 
44
+ # Expose the port the app runs on
45
+ EXPOSE 8000
46
+
47
+ # Define the command to run the application using uvicorn
48
+ # Use --host 0.0.0.0 to make it accessible from outside the container
49
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
50
+
51
+ # ----------- END Dockerfile -----------