# Native Dash gallery image. Build context = repo root:
#   docker build -f examples/dash_gallery/Dockerfile -t tensorgrid-dash .
#
# Installs the dash-tensor-grid wheel from source (the JS bundle is committed, so
# no npm is needed) and serves the gallery under gunicorn. Mounted at /dash/ in
# production via TG_URL_BASE; Polars threads are capped for a small, safe pool.
FROM python:3.12-slim

WORKDIR /src
# Only what `pip install .` (hatchling) and the app need — keeps the layer small.
COPY pyproject.toml README.md LICENSE ./
COPY dash_tensor_grid ./dash_tensor_grid
COPY examples ./examples

RUN pip install --no-cache-dir . gunicorn

ENV TG_URL_BASE=/dash/ \
    POLARS_MAX_THREADS=4 \
    RAYON_NUM_THREADS=4 \
    OMP_NUM_THREADS=2 \
    OPENBLAS_NUM_THREADS=2 \
    MKL_NUM_THREADS=2 \
    NUMEXPR_NUM_THREADS=2 \
    VECLIB_MAXIMUM_THREADS=2

WORKDIR /src/examples/dash_gallery
EXPOSE 8050
# Single worker so the in-memory demo state (edit store) is consistent; a few
# threads for concurrent asset/callback requests.
CMD ["gunicorn", "-b", "0.0.0.0:8050", "-w", "1", "--threads", "4", "app:server"]
