FROM python:3.11-slim

WORKDIR /app

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV UV_PROJECT_ENVIRONMENT=/usr/local

# Install uv for dependency management inside the container.
RUN pip install --no-cache-dir uv

# Copy dependency manifests first for layer caching.
COPY pyproject.toml uv.lock* ./

# Install project dependencies into the system environment.
RUN uv sync --no-dev --no-install-project --frozen 2>/dev/null || uv sync --no-dev --no-install-project

# Copy project source after dependency layers.
COPY . .

# Install the project itself and keep runtime dependencies in sync.
RUN uv sync --no-dev --frozen 2>/dev/null || uv sync --no-dev

# Install lambda_agent_api from the local source tree, bypassing its Python version guard.
RUN pip install --no-cache-dir --ignore-requires-python /app/external/platform-agent_api

CMD ["python", "-m", "adapter.matrix.bot"]
