philipobiorah commited on
Commit
665bb42
·
verified ·
1 Parent(s): 243879b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -14
Dockerfile CHANGED
@@ -1,37 +1,39 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.10-slim
3
 
4
- # Set the working directory to /app
5
  WORKDIR /app
6
 
7
- # Install system dependencies for machine learning and data processing
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  libopenblas-dev \
11
  libomp-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Create writable cache directories for Hugging Face and Matplotlib
15
- RUN mkdir -p /tmp/huggingface_cache /tmp/matplotlib
 
16
 
17
- # Set environment variables for cache paths
18
- ENV HF_HOME=/tmp/huggingface_cache
19
- ENV MPLCONFIGDIR=/tmp/matplotlib
 
20
 
21
- # Copy requirements.txt to leverage Docker caching
22
  COPY requirements.txt /app/requirements.txt
23
 
24
  # Install dependencies
25
- RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Install PyTorch separately to ensure compatibility with the correct architecture
28
  RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
29
 
30
- # Copy the rest of the application code
31
  COPY . /app
32
 
33
- # Expose port 7860 for Flask app
34
  EXPOSE 7860
35
 
36
- # Run the Flask application
37
  CMD ["python", "main.py"]
 
1
+ # Use Python 3.10 for compatibility
2
  FROM python:3.10-slim
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  libopenblas-dev \
11
  libomp-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Create writable directories
15
+ RUN mkdir -p /tmp/huggingface_cache /tmp/matplotlib \
16
+ && chmod -R 777 /tmp/huggingface_cache /tmp/matplotlib
17
 
18
+ # Set cache environment variables
19
+ ENV HF_HOME=/tmp
20
+ ENV TRANSFORMERS_CACHE=/tmp
21
+ ENV MPLCONFIGDIR=/tmp
22
 
23
+ # Copy requirements file
24
  COPY requirements.txt /app/requirements.txt
25
 
26
  # Install dependencies
27
+ RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
28
 
29
+ # Install PyTorch separately for compatibility
30
  RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
31
 
32
+ # Copy application files
33
  COPY . /app
34
 
35
+ # Expose Flask app port
36
  EXPOSE 7860
37
 
38
+ # Run the application
39
  CMD ["python", "main.py"]