FROM mcr.microsoft.com/playwright/python:v1.49.1-noble

WORKDIR /app

# Node.js 20
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs

# Poetry
RUN pip install poetry

# Python deps
COPY pyproject.toml poetry.lock* ./
RUN poetry config virtualenvs.create false \
    && poetry install --no-interaction --no-ansi --no-root

# MCP server deps
COPY mcp/package*.json ./mcp/
RUN cd mcp && npm install --production

# Code
COPY . .
RUN poetry install --no-interaction --no-ansi

# Playwright MCP
RUN npm install -g @playwright/mcp

# Data dir
RUN mkdir -p /data/egrul-pdfs

EXPOSE 8000
CMD ["python", "app.py"]
