FROM python:3.10-slim WORKDIR /app # 1. Install essential system dependencies RUN apt-get update && apt-get install -y \ gcc \ python3-dev \ libgomp1 \ libopenblas-dev \ && rm -rf /var/lib/apt/lists/* # 2. First install only absolutely critical packages RUN pip install --upgrade pip && \ pip install --no-cache-dir \ spacy==3.7.4 \ nltk==3.8.1 \ python-dotenv==1.0.0 # 3. Download NLP models (done before other installs to prevent conflicts) RUN python -m spacy download en_core_web_sm && \ python -m nltk.downloader punkt wordnet # 4. Install PyTorch CPU version explicitly RUN pip install --no-cache-dir \ torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu # 5. Install remaining requirements in one go to minimize layers COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 6. Copy application files COPY . . # 7. Environment configuration ENV STREAMLIT_SERVER_PORT=7860 EXPOSE 7860 CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]