FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONFAULTHANDLER=1 \ PYTHONHASHSEED=random \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_DEFAULT_TIMEOUT=300 \ MODEL_CACHE_DIR=/data/models \ DEBIAN_FRONTEND=noninteractive # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ git \ gcc \ g++ \ libgl1 \ libglib2.0-0 \ libsm6 \ libxrender1 \ libxext6 \ libgl1-mesa-glx \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Install pip and setuptools RUN pip install --upgrade pip setuptools wheel # Install system-level dependencies for Python packages RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ python3-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Install Playwright and its dependencies RUN pip install playwright==1.42.0 && \ playwright install --with-deps chromium # Copy application code COPY . . # Install the package in development mode RUN pip install -e . # Create models directory for persistent storage RUN mkdir -p ${MODEL_CACHE_DIR} && chmod 777 ${MODEL_CACHE_DIR} # Set environment variables ENV HOST=0.0.0.0 \ PORT=8501 \ STREAMLIT_SERVER_PORT=8501 \ STREAMLIT_SERVER_HEADLESS=true \ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \ PYTHONPATH="/app/src:${PYTHONPATH}" \ PYTHONUNBUFFERED=1 # Install the package in development mode WORKDIR /app COPY . . # Install the package in development mode RUN pip install -e . # Install Playwright browsers RUN playwright install --with-deps # Expose port EXPOSE 8501 # Set the working directory to the app root WORKDIR /app # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl --fail http://localhost:8501/_stcore/health || exit 1 # Command to run the Streamlit app CMD ["streamlit", "run", "app.py"]