# Compute module image for the interactive routing engine.
#
# Foundry requires linux/amd64 images and a numeric non-root USER.
#
# Build context: this directory, with the two wheels copied into ./wheels:
#   pyroutingkit-*-manylinux*x86_64.whl  (from pyroutingkit's cibuildwheel CI)
#   hum_router-*-py3-*.whl        (uv build in hum-router)
#
#   docker build --platform linux/amd64 -t hum-router-cm .
#
# Graph access (see bootstrap.py): mount the T2 graph dataset as a module
# resource aliased 'graph' (preferred), or set FOUNDRY_URL + FOUNDRY_TOKEN
# + GRAPH_DATASET_RID, or pre-mount files at /data/graph.

FROM --platform=linux/amd64 python:3.12-slim

# Foundry compute modules require a non-root user
RUN useradd --uid 5000 --create-home user
WORKDIR /app

COPY wheels/ /tmp/wheels/
RUN pip install --no-cache-dir \
        /tmp/wheels/*.whl \
        foundry-compute-modules \
        requests \
    && rm -rf /tmp/wheels

COPY app.py bootstrap.py /app/

RUN mkdir -p /data/graph && chown -R 5000:5000 /data /app
USER 5000

ENTRYPOINT ["python", "/app/app.py"]
