FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends gcc && \
    rm -rf /var/lib/apt/lists/*

# Upgrade pip and set workdir
WORKDIR /app
RUN pip install --no-cache-dir --upgrade pip setuptools

# Install Python dependencies first (for better layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn==21.2.0

# Copy application code
COPY . .

# Use Gunicorn with the configuration file
CMD ["gunicorn", "-c", "logstats/gunicorn.conf.py", "logstats.log_stats_deltalake:app"]

# For local development, you can override the command with:
# docker run -p 8080:8080 your-image python logstats/log_stats_deltalake.py
