FROM python:3.13-slim

# Install system deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    nodejs npm \
    git \
    sudo \
    && rm -rf /var/lib/apt/lists/*

# Install JupyterHub, JupyterLab, notebook (required for singleuser), and DockerSpawner
RUN pip install --no-cache-dir jupyterhub jupyterlab notebook dockerspawner

# Install configurable-http-proxy (required by JupyterHub)
RUN npm install -g configurable-http-proxy@^4.0.0

# Ensure npm global binaries are available in PATH
ENV PATH="/usr/local/bin:${PATH}"

# Create directories
RUN mkdir -p /srv/jupyterhub /srv/jupyterhub/data
WORKDIR /srv/jupyterhub

COPY jupyterhub_config.py /srv/jupyterhub/

EXPOSE 8001

CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]
