File size: 1,715 Bytes
0cda118
 
 
 
 
 
 
985c72d
 
0cda118
 
 
 
 
 
 
 
 
985c72d
0cda118
 
985c72d
 
 
 
 
0cda118
 
4284834
 
 
 
 
 
 
 
 
 
 
 
 
0cda118
 
 
4284834
 
 
 
0cda118
0e562e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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"]