# LAIDA CLI - Multi-stage Docker build
# =====================================

# Stage 1: Builder
FROM python:3.11-slim as builder

WORKDIR /app

# Install build dependencies
RUN pip install --no-cache-dir build

# Copy source code
COPY pyproject.toml .
COPY src/ src/

# Build the package
RUN python -m build --wheel

# Stage 2: Runtime
FROM python:3.11-slim as runtime

# Create non-root user for security
RUN useradd --create-home --shell /bin/bash laida

WORKDIR /home/laida

# Copy wheel from builder
COPY --from=builder /app/dist/*.whl /tmp/

# Install the package
RUN pip install --no-cache-dir /tmp/*.whl && rm /tmp/*.whl

# Switch to non-root user
USER laida

# Set working directory for projects
WORKDIR /project

# Default command
ENTRYPOINT ["laida"]
CMD ["--help"]
