# GeoRank AI — Self-hosted search, AI-visibility and performance intelligence.
# Build: docker build -t georank-ai:0.1.0 .
# Run:   docker run -d -p 8321:8321 -v $(pwd)/data:/app/data -e GEORANK_MASTER_KEY=... georank-ai:0.1.0

FROM python:3.12-slim AS base

# Install Node.js + pnpm for Unlighthouse perf sidecar
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl ca-certificates gnupg && \
    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    npm install -g pnpm && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy vendor/unlighthouse for perf sidecar
COPY vendor/unlighthouse ./vendor/unlighthouse
RUN cd /app/vendor/unlighthouse && pnpm install --frozen-lockfile && pnpm -r run build

# Install Python package
COPY pyproject.toml README.md LICENSE NOTICE ./ 
COPY georank ./georank
COPY brand-kit ./brand-kit
COPY brand-assets ./brand-assets

# Install in editable mode so demo.py works
RUN pip install --no-cache-dir -e .[fast]

# Create data directory with restrictive permissions
RUN mkdir -p /app/data && chmod 700 /app/data

ENV GEORANK_HOME=/app/data
ENV PYTHONUNBUFFERED=1

EXPOSE 8321

# Entrypoint handles init if needed, then starts dashboard
ENTRYPOINT ["/app/docker-entrypoint.sh"]
