# Dockerfile for View Manager
# Production-ready container for database view management

FROM python:3.13-slim

# Set working directory
WORKDIR /app

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

# Install uv for fast Python package management
RUN pip install --no-cache-dir uv

# Copy project files
COPY pyproject.toml README.md ./
COPY src/ ./src/
COPY metadata.yaml ./metadata.yaml

# Install Python dependencies using uv
RUN uv pip install --system -e .

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app

# Health check - verify database connection
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
    CMD python -c "import asyncio; from meta_api_grabber.database import TimescaleDBClient; asyncio.run(TimescaleDBClient().connect())" || exit 1

# Run the view manager setup
CMD ["uv", "run", "view-manager-setup"]
