Initial commit
This commit is contained in:
commit
7e24a0c751
|
@ -0,0 +1 @@
|
|||
/data
|
|
@ -0,0 +1,40 @@
|
|||
FROM jupyterhub/jupyterhub
|
||||
|
||||
ARG HTTP_PROXY=
|
||||
ARG HTTPS_PROXY=
|
||||
ARG http_proxy=
|
||||
ARG https_proxy=
|
||||
|
||||
ARG TUTOR_USERNAME=tutor
|
||||
ARG TUTOR_PASSWORD=tutor
|
||||
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y curl ca-certificates \
|
||||
&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \
|
||||
&& apt-get install -y nodejs libzmq3-dev mcrypt
|
||||
|
||||
RUN pip install jupyter
|
||||
|
||||
RUN npm install -g ijavascript \
|
||||
&& ijs --ijs-install=global
|
||||
|
||||
RUN useradd -m $TUTOR_USERNAME \
|
||||
&& echo "$TUTOR_USERNAME:$TUTOR_PASSWORD" | chpasswd
|
||||
|
||||
RUN mkdir -p /home/$TUTOR_USERNAME/lessons \
|
||||
&& mkdir -p /home/$TUTOR_USERNAME/students \
|
||||
&& chown -R $TUTOR_USERNAME: /home/$TUTOR_USERNAME
|
||||
|
||||
RUN echo "TUTOR_USERNAME=$TUTOR_USERNAME" > /srv/jupyterhub/tutor.conf
|
||||
|
||||
ADD create-hub-student.sh /usr/local/bin/create-hub-student
|
||||
RUN chmod +x /usr/local/bin/create-hub-student
|
||||
|
||||
RUN mkdir -p /etc/jupyterhub \
|
||||
&& cd /etc/jupyterhub \
|
||||
&& jupyterhub --generate-config \
|
||||
&& sed -i "s/^#c.Authenticator.admin_users = set()$/c.Authenticator.admin_users = set(['$TUTOR_USERNAME'])/" jupyterhub_config.py \
|
||||
&& sed -i "s/^#c.LocalAuthenticator.create_system_users = False$/c.LocalAuthenticator.create_system_users = True/" jupyterhub_config.py \
|
||||
&& sed -i "s/^#c.LocalAuthenticator.add_user_cmd = \[\]$/c.LocalAuthenticator.add_user_cmd = ['\/usr\/local\/bin\/create-hub-student']/" jupyterhub_config.py
|
||||
|
||||
CMD ["jupyterhub", "--config", "/etc/jupyterhub/jupyterhub_config.py"]
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
USERNAME=$1
|
||||
|
||||
source /srv/jupyterhub/tutor.conf
|
||||
|
||||
if [ -z "$USERNAME" ]; then
|
||||
echo "You must provide a valid username as first argument !" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "$USERNAME\n$USERNAME\n" | adduser -q --gecos "" $USERNAME
|
||||
|
||||
# Expose student work to tutor
|
||||
mkdir -p /home/$TUTOR_USERNAME/students
|
||||
ln -s /home/$USERNAME /home/$TUTOR_USERNAME/students/$USERNAME
|
||||
chown $TUTOR_USERNAME: /home/$TUTOR_USERNAME/students/$USERNAME
|
||||
|
||||
#Expose tutor's lessons to student
|
||||
mkdir -p /home/$TUTOR_USERNAME/lessons
|
||||
chown $TUTOR_USERNAME: /home/$TUTOR_USERNAME/lessons
|
||||
ln -s /home/$TUTOR_USERNAME/lessons /home/$USERNAME/lessons
|
||||
|
||||
chown $USERNAME: /home/$USERNAME
|
|
@ -0,0 +1,18 @@
|
|||
version: "2"
|
||||
services:
|
||||
hub:
|
||||
build:
|
||||
context: containers/hub
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- HTTP_PROXY=${HTTP_PROXY}
|
||||
- HTTPS_PROXY=${HTTPS_PROXY}
|
||||
- http_proxy=${http_proxy}
|
||||
- https_proxy=${https_proxy}
|
||||
- TUTOR_USERNAME=tutor
|
||||
- TUTOR_PASSWORD=tutor
|
||||
ports:
|
||||
- 8000:8000
|
||||
volumes:
|
||||
- ./data/lessons:/home/tutor/lessons
|
||||
- ./data/students:/home/tutor/students
|
Loading…
Reference in New Issue