FROM python:3.11-slim

WORKDIR /app

# Install system dependencies including docker and build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    docker.io \
    docker-compose \
    build-essential \
    ca-certificates \
    curl \
    && rm -rf /var/lib/apt/lists/* \
    && ln -sf /usr/bin/docker.io /usr/local/bin/docker \
    && ln -sf /usr/bin/docker.io /usr/bin/docker || true

# Copy dependency files
COPY pyproject.toml README.md ./

# Install the package with dev dependencies
RUN pip install --no-cache-dir -e ".[dev]"

# Copy the application code
COPY sindri/ ./sindri/

# Create entrypoint script that changes to /ws before running sindri
# Set PYTHONPATH to ensure sindri module is found after cd to /ws
RUN echo '#!/bin/sh\ncd /ws 2>/dev/null || true\nexport PYTHONPATH=/app:$PYTHONPATH\nexec sindri "$@"' > /entrypoint.sh && \
    chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]


