himanshukumar378 commited on
Commit
c6246b4
·
verified ·
1 Parent(s): 939b1d5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -16
Dockerfile CHANGED
@@ -2,38 +2,37 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
- # 1. Install system dependencies with cleanup
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  python3-dev \
9
- git \
10
  libgomp1 \
11
  libopenblas-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # 2. First install PyTorch with CPU-only version
15
  RUN pip install --upgrade pip && \
16
- pip install torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
 
 
 
17
 
18
- # 3. Install Hugging Face transformers from source (more reliable)
19
- RUN pip install git+https://github.com/huggingface/transformers@v4.42.4
 
20
 
21
- # 4. Install other heavy dependencies
22
- RUN pip install \
23
- sentence-transformers==3.0.1 \
24
- faiss-cpu==1.7.4 \
25
- --no-cache-dir
26
 
27
- # 5. Copy and install remaining requirements
28
  COPY requirements.txt .
29
- RUN pip install -r requirements.txt --no-cache-dir && \
30
- python -m spacy download en_core_web_sm && \
31
- python -m nltk.downloader punkt wordnet
32
 
33
  # 6. Copy application files
34
  COPY . .
35
 
36
- # Environment configuration
37
  ENV STREAMLIT_SERVER_PORT=7860
38
  EXPOSE 7860
39
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # 1. Install essential system dependencies
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  python3-dev \
 
9
  libgomp1 \
10
  libopenblas-dev \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # 2. First install only absolutely critical packages
14
  RUN pip install --upgrade pip && \
15
+ pip install --no-cache-dir \
16
+ spacy==3.7.4 \
17
+ nltk==3.8.1 \
18
+ python-dotenv==1.0.0
19
 
20
+ # 3. Download NLP models (done before other installs to prevent conflicts)
21
+ RUN python -m spacy download en_core_web_sm && \
22
+ python -m nltk.downloader punkt wordnet
23
 
24
+ # 4. Install PyTorch CPU version explicitly
25
+ RUN pip install --no-cache-dir \
26
+ torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
 
 
27
 
28
+ # 5. Install remaining requirements in one go to minimize layers
29
  COPY requirements.txt .
30
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
31
 
32
  # 6. Copy application files
33
  COPY . .
34
 
35
+ # 7. Environment configuration
36
  ENV STREAMLIT_SERVER_PORT=7860
37
  EXPOSE 7860
38