vishalsh13 commited on
Commit
ecf18d6
·
1 Parent(s): c142783

updatecode

Browse files
Files changed (2) hide show
  1. Dockerfile +21 -29
  2. requirements.txt +10 -11
Dockerfile CHANGED
@@ -1,48 +1,40 @@
1
- # base image with Ubuntu 20.04
2
- FROM ubuntu:20.04
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
 
8
- # Add deadsnakes PPA for Python 3.11
9
- RUN apt-get update && apt-get install -y software-properties-common && \
10
- add-apt-repository -y ppa:deadsnakes/ppa && \
11
- apt-get update
 
 
 
 
12
 
13
- # Install Python 3.11 and required packages
14
- RUN apt-get install -y \
15
- python3.11 python3.11-distutils python3.11-dev wget git unzip && \
16
- rm -rf /var/lib/apt/lists/*
17
-
18
- # Install pip using get-pip.py (bypasses any outdated or broken system pip)
19
- RUN wget https://bootstrap.pypa.io/get-pip.py && \
20
- python3.11 get-pip.py && \
21
- rm get-pip.py
22
-
23
- # Update alternatives to set Python 3.11 as default
24
- RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
25
- update-alternatives --config python3
26
 
27
  # Set Hugging Face cache directory
28
  ENV HF_HOME=/app/cache
29
  RUN mkdir -p /app/cache && chmod -R 777 /app/cache
30
 
 
 
 
 
 
 
31
  # Create directories with proper read/write permissions
32
  RUN mkdir -p /app/uploads/vectors && chmod -R 777 /app/uploads
33
 
34
- # Set the working directory
35
- WORKDIR /app
36
-
37
- # Copy the application files
38
  COPY . .
39
 
40
- # Install Python dependencies
41
- RUN pip install --no-cache-dir -r requirements.txt
42
- RUN python3 -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', cache_folder='/app/cache')"
43
-
44
- # Expose the Flask app's port
45
  EXPOSE 7860
46
 
47
  # Start the Flask app
48
- CMD ["python3", "run.py"]
 
1
+ # Use the official Python 3.11 slim image
2
+ FROM python:3.11-slim
3
 
4
  # Set environment variables
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
 
8
+ # Install basic build tools and libraries (required by faiss-cpu, PyMuPDF, etc.)
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ build-essential \
11
+ cmake \
12
+ libopenblas-dev \
13
+ libomp-dev \
14
+ poppler-utils \
15
+ && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Create a working directory
18
+ WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  # Set Hugging Face cache directory
21
  ENV HF_HOME=/app/cache
22
  RUN mkdir -p /app/cache && chmod -R 777 /app/cache
23
 
24
+ # Copy requirements first (for Docker layer caching)
25
+ COPY requirements.txt .
26
+
27
+ # Install Python dependencies (no version pinning)
28
+ RUN pip install --no-cache-dir -r requirements.txt
29
+
30
  # Create directories with proper read/write permissions
31
  RUN mkdir -p /app/uploads/vectors && chmod -R 777 /app/uploads
32
 
33
+ # Copy the rest of the application files
 
 
 
34
  COPY . .
35
 
36
+ # Expose the port used by your Flask app (e.g., 7860)
 
 
 
 
37
  EXPOSE 7860
38
 
39
  # Start the Flask app
40
+ CMD ["python", "run.py"]
requirements.txt CHANGED
@@ -1,11 +1,10 @@
1
- Flask==2.3.2
2
- transformers==4.31.0
3
- sentence-transformers==2.2.2
4
- torch==2.0.1
5
- torchvision==0.15.2
6
- faiss-cpu==1.7.2
7
- PyMuPDF==1.22.5
8
- python-pptx==0.6.21
9
- pandas==1.5.3
10
- numpy==1.24.2
11
- huggingface-hub==0.15.1
 
1
+ Flask
2
+ transformers
3
+ sentence-transformers
4
+ torch
5
+ faiss-cpu
6
+ PyMuPDF
7
+ python-pptx
8
+ pandas
9
+ numpy
10
+ huggingface-hub