mic3333 commited on
Commit
4fc2ef6
·
1 Parent(s): 32acb38

Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -16
Dockerfile CHANGED
@@ -2,39 +2,37 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /code
4
 
5
- # Install system dependencies required for building some Python packages
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  g++ \
9
  git \
10
  wget \
11
- ffmpeg \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Set environment variables for Hugging Face cache and tokenizers
15
- ENV HF_HOME=/code/cache
16
  ENV TRANSFORMERS_CACHE=/code/cache
 
17
  ENV TOKENIZERS_PARALLELISM=false
18
 
19
- # Copy requirements first for better Docker layer caching
20
  COPY requirements.txt /code/requirements.txt
21
 
22
- # Upgrade pip and install Python dependencies
23
  RUN pip install --no-cache-dir --upgrade pip
24
- RUN pip install --no-cache-dir -r /code/requirements.txt
25
 
26
- # Pre-download the models at build time to avoid runtime delays.
27
- # This ensures the application starts up quickly in the Space.
28
- # RUN python -c "from transformers import pipeline; import whisper; pipeline('summarization', model='facebook/bart-large-cnn'); whisper.load_model('base', download_root='/code/cache')"
29
 
30
- # Copy the rest of the application code into the container
31
- COPY . /code/
32
 
33
- # Create the cache directory (the ENV variables point here)
34
  RUN mkdir -p /code/cache
35
 
36
- # Expose the port Gradio runs on
37
  EXPOSE 7860
38
 
39
- # Command to run the application
40
- CMD ["python3", "app.py"]
 
2
 
3
  WORKDIR /code
4
 
5
+ # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  g++ \
9
  git \
10
  wget \
 
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Set environment variables
 
14
  ENV TRANSFORMERS_CACHE=/code/cache
15
+ ENV HF_HOME=/code/cache
16
  ENV TOKENIZERS_PARALLELISM=false
17
 
18
+ # Copy requirements first for better caching
19
  COPY requirements.txt /code/requirements.txt
20
 
21
+ # Install Python dependencies
22
  RUN pip install --no-cache-dir --upgrade pip
23
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
24
 
25
+ # Download models at build time to avoid runtime delays
26
+ RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
 
27
 
28
+ # Copy the application code
29
+ COPY . /code
30
 
31
+ # Create cache directory
32
  RUN mkdir -p /code/cache
33
 
34
+ # Expose port 7860 for Hugging Face Spaces
35
  EXPOSE 7860
36
 
37
+ # Run the application
38
+ CMD ["python", "app.py"]