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

# Copy project source after dependency layers.
COPY . .

# Install the project itself.
RUN uv sync --no-dev --frozen

# Install lambda_agent_api from the vendored source tree.
# --ignore-requires-python: the package declares python<3.12 but works fine on 3.11;
# the guard exists for its own dev tooling, not the runtime API surface we use.
RUN pip install --no-cache-dir --ignore-requires-python /app/external/platform-agent_api

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