FROM mcr.microsoft.com/playwright:v1.55.0-noble
COPY --from=ghcr.io/astral-sh/uv:0.12.15 /uv /uvx /bin/

ENV UV_PROJECT_ENVIRONMENT=/opt/venv \
    PATH="/opt/venv/bin:${PATH}" \
    PYTHONUNBUFFERED=1 \
    PLAYWRIGHT_BROWSERS_PATH=/ms-playwright

WORKDIR /workspace
RUN apt-get update \
    && apt-get install -y --no-install-recommends build-essential python3-venv \
    && rm -rf /var/lib/apt/lists/*
COPY pyproject.toml README.md LICENSE ./
COPY src ./src
COPY examples ./examples
RUN uv sync \
       --project examples/engineering_change_investigator \
       --frozen \
       --no-dev \
    && npm install --global \
       @modelcontextprotocol/server-filesystem@2026.8.31 \
       @modelcontextprotocol/server-everything@2026.8.31 \
       @playwright/mcp@0.0.82 \
    && npx playwright install chromium \
    && ln -s "$(find /ms-playwright -type f -path '*/chrome-linux64/chrome' | head -n1)" \
       /usr/local/bin/agloom-chromium

WORKDIR /workspace/examples/engineering_change_investigator
CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "8000"]
