cigol123 commited on
Commit
2986566
·
verified ·
1 Parent(s): c82d30f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -10
Dockerfile CHANGED
@@ -1,20 +1,34 @@
1
- # Stage 1: Build
2
- FROM python:3.9-slim as builder
 
 
 
 
3
 
 
 
 
 
4
  WORKDIR /app
 
 
5
  COPY requirements.txt .
6
- RUN pip install --no-cache-dir --user -r requirements.txt
7
 
8
- # Stage 2: Final Image
9
- FROM python:3.9-slim
10
- WORKDIR /app
 
 
 
 
11
 
12
- # Copy only the necessary files from the builder stage
13
- COPY --from=builder /root/.local /root/.local
14
  COPY . .
15
 
16
- # Ensure scripts in .local are usable
17
- ENV PATH=/root/.local/bin:$PATH
 
 
18
 
19
  # Expose port 7860 (default port for Gradio)
20
  EXPOSE 7860
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
+
4
+ # Set environment variables for Hugging Face cache
5
+ ENV TRANSFORMERS_CACHE=/app/.cache
6
+ ENV HF_DATASETS_CACHE=/app/.cache
7
 
8
+ # Create the cache directory
9
+ RUN mkdir -p /app/.cache
10
+
11
+ # Set the working directory in the container
12
  WORKDIR /app
13
+
14
+ # Copy the requirements file into the container
15
  COPY requirements.txt .
 
16
 
17
+ # Install system dependencies (required for soundfile and other libraries)
18
+ RUN apt-get update && apt-get install -y \
19
+ libsndfile1 \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Install Python dependencies
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
 
25
+ # Copy the current directory contents into the container
 
26
  COPY . .
27
 
28
+ # Pre-download the Whisper model during the build process
29
+ RUN python -c "from transformers import WhisperProcessor, WhisperForConditionalGeneration; \
30
+ WhisperProcessor.from_pretrained('openai/whisper-large-v3', cache_dir='/app/.cache'); \
31
+ WhisperForConditionalGeneration.from_pretrained('openai/whisper-large-v3', cache_dir='/app/.cache')"
32
 
33
  # Expose port 7860 (default port for Gradio)
34
  EXPOSE 7860