FROM debian:bookworm-slim

LABEL maintainer="franck.garnier" \
      description="Mars rover panorama stitching pipeline - Hugin 2024 + Python + OpenCV"

# Install Hugin CLI tools + Python + dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    hugin-tools \
    enblend \
    python3 \
    python3-pip \
    python3-venv \
    python3-numpy \
    python3-opencv \
    python3-pil \
    python3-mysql.connector \
    wget \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Install additional Python packages
RUN pip3 install --no-cache-dir --break-system-packages \
    requests \
    python-dotenv

# Create working directories
RUN mkdir -p /data /output /app

WORKDIR /app

# Copy pipeline scripts
COPY pipeline/ /app/

# Make scripts executable
RUN chmod +x /app/*.py 2>/dev/null || true
RUN chmod +x /app/*.sh 2>/dev/null || true

# Verify installations
RUN nona 2>&1 | head -1 || true && \
    cpfind 2>&1 | head -1 || true && \
    enblend --version 2>&1 | head -1 || true && \
    python3 -c "import cv2; print(f'OpenCV {cv2.__version__}')" && \
    python3 -c "import numpy; print(f'NumPy {numpy.__version__}')" && \
    python3 -c "from PIL import Image; print('Pillow OK')"

ENTRYPOINT ["python3", "/app/panorama_pipeline.py"]
CMD ["--help"]
