FROM python:3.12-slim
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Overlay: PinScope inherited tree, then native Periscope modules.
COPY periscope/src/backend/requirements*.txt /app/backend/
RUN pip install --no-cache-dir -r /app/backend/requirements.txt \
 && if [ -f /app/backend/requirements-gateway.txt ]; then \
      pip install --no-cache-dir -r /app/backend/requirements-gateway.txt; \
    fi

COPY periscope/dependency/backend/ /app/backend/
COPY periscope/src/backend/ /app/backend/

COPY periscope/dependency/taxonomy/ /app/taxonomy/
COPY periscope/src/taxonomy/ /app/taxonomy/
COPY periscope/dependency/skills/ /app/skills/
COPY periscope/src/skills/ /app/skills/
COPY periscope/dependency/frontend/content/changelog.md /app/changelog.md
COPY periscope/src/frontend/content/changelog.md /app/changelog.md
COPY vendor/ /app/vendor/

EXPOSE 8080

CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080"]
