# Base image with Python and basic utilities FROM python:3.9-slim # Set working directory WORKDIR /app # Install Git LFS (needed for model files) # Also install git itself, as it might not be in python:3.9-slim and is needed by LFS RUN apt-get update && apt-get install -y git git-lfs && git-lfs install --system # Copy requirements first to leverage Docker caching COPY requirements.txt requirements.txt # Install dependencies # Using --no-cache-dir to reduce image size # Using --prefer-binary for faster installs where available RUN pip install --no-cache-dir --prefer-binary -r requirements.txt # Copy the rest of the application code (including LFS pointer files) COPY . . # Pull LFS files (download the actual model specified in .gitattributes) RUN git lfs pull # Make model directory if it doesn't exist (though LFS pull should handle it) # This is more of a safeguard if no LFS files are present but the dir is expected RUN mkdir -p models # Add some debugging info RUN echo "=== Container Debug Info ===" && \ echo "Python version:" && python --version && \ echo "Working directory:" && pwd && \ echo "Directory contents:" && ls -la && \ echo "Models directory:" && ls -la models/ && \ echo "Database file:" && ls -la database.csv && \ echo "Requirements:" && cat requirements.txt # Set environment variables for better Python behavior in containers ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 # Expose the port Gradio will run on (default 7860) EXPOSE 7860 # Add health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Command to run the application CMD ["python", "app.py"]