FROM python:3.12-slim

RUN apt-get update \
    && apt-get install -y --no-install-recommends nodejs npm ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY pyproject.toml ./
COPY package.json ./
RUN pip install --no-cache-dir \
        "fastapi>=0.115.0,<1.0" \
        "httpx>=0.27.0,<1.0" \
        "pydantic>=2.7.0,<3.0" \
        "qrcode>=8.0,<9.0" \
        "uvicorn[standard]>=0.30.0,<1.0" \
    && npm install --omit=dev --package-lock=false

COPY external_connector ./external_connector

ENV CONNECTOR_HOME=/var/lib/external-connector
EXPOSE 8787

CMD ["python", "-m", "external_connector.main"]
