Athspi commited on
Commit
2cdd6eb
·
verified ·
1 Parent(s): 1602673

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -34
Dockerfile CHANGED
@@ -1,47 +1,28 @@
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 7860
45
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
46
 
47
- # ----------- END Dockerfile -----------
 
 
 
1
  # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
 
 
 
3
 
4
  # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE 1
6
+ ENV PYTHONUNBUFFERED 1
 
 
7
 
8
  # Install system dependencies
9
+ RUN apt-get update && apt-get install -y \
 
 
 
10
  ffmpeg \
11
+ libsndfile1 \
 
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Set work directory
15
+ WORKDIR /app
 
 
 
 
 
 
 
 
16
 
17
+ # Copy app files
18
+ COPY . /app/
 
 
19
 
20
+ # Install Python dependencies
21
+ RUN pip install --no-cache-dir --upgrade pip \
22
+ && pip install --no-cache-dir -r requirements.txt
23
 
24
+ # Expose port
25
  EXPOSE 7860
 
26
 
27
+ # Command to run the FastAPI app with Uvicorn
28
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]