# Dockerfile for JupyterHub with authenticator
FROM jupyterhub/jupyterhub:5.3.0

USER root

RUN apt-get update && apt-get install -y --no-install-recommends git sudo && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir \
    git+https://github.com/jupyterhub/nativeauthenticator.git@main \
    oauthenticator \
    jupyterhub-idle-culler \
    jupyterlab \
    notebook

# Create eric user with password-less sudo
RUN useradd -m -s /bin/bash -u 1000 eric && \
    echo "eric ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
    chown -R eric:eric /home/eric

# Create the directory for JupyterHub data
RUN mkdir -p /srv/jupyterhub && chown -R 1000:1000 /srv/jupyterhub

ARG BUILD_DATE=unknown
RUN echo "Build date: ${BUILD_DATE}" > /tmp/build-info.txt

COPY jupyterhub_config.py /srv/jupyterhub/jupyterhub_config.py

WORKDIR /srv/jupyterhub

EXPOSE 8000

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