diff --git a/Dockerfile b/Dockerfile index 2a6e3e5..7fee186 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,9 +39,11 @@ EXPOSE 5000 COPY usr/share/jupyter-canvas-api/api-server.py /usr/share/jupyter-canvas-api/api-server.py COPY usr/share/jupyter-canvas-api/requirements.txt /usr/share/jupyter-canvas-api/requirements.txt COPY usr/local/bin/hourly-rsync.sh /etc/cron.hourly/hourly-api-rsync +COPY docker-entrypoint.sh / RUN mkdir /mnt/efs RUN chmod +x /etc/cron.hourly/hourly-api-rsync RUN touch /etc/crontab /etc/cron.*/* WORKDIR /usr/share/jupyter-canvas-api/ RUN pip3 install -r /usr/share/jupyter-canvas-api/requirements.txt +ENTRYPOINT ["/docker-entrypoint.sh"] CMD printenv | grep -v "no_proxy" > /etc/environment && /etc/init.d/cron start && python3 -u /usr/share/jupyter-canvas-api/api-server.py diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..120d3a6 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eo pipefail + +BASE_DIR="${BASE_DIR:-/mnt/efs}" +DEFAULT_JNOTE_HOME="$BASE_DIR/${JNOTE_COURSE_CODE,,}" +DEFAULT_JNOTE_SNAP="$BASE_DIR/${JNOTE_COURSE_CODE,,}-snap" +DEFAULT_JNOTE_INTSNAP="$BASE_DIR/${JNOTE_COURSE_CODE,,}-internal" + +export JNOTE_HOME="${JNOTE_HOME:-$DEFAULT_JNOTE_HOME}" +export JNOTE_SNAP="${JNOTE_SNAP:-$DEFAULT_JNOTE_SNAP}" +export JNOTE_INTSNAP="${JNOTE_INTSNAP:-$DEFAULT_JNOTE_INTSNAP}" + +mkdir -p $JNOTE_HOME $JNOTE_SNAP $JNOTE_INTSNAP +chmod 777 $JNOTE_HOME $JNOTE_SNAP $JNOTE_INTSNAP + +exec "$@" diff --git a/kube-manifests/jupyterhub-api-pod.yml b/kube-manifests/jupyterhub-api-pod.yml index 447ccba..7c4897a 100644 --- a/kube-manifests/jupyterhub-api-pod.yml +++ b/kube-manifests/jupyterhub-api-pod.yml @@ -11,7 +11,7 @@ metadata: spec: replicas: 1 selector: - matchLabels: + matchLabels: run: jupyterhub-api-app app: jhub-api organization: ubc @@ -34,10 +34,10 @@ spec: memory: 2G limits: cpu: "500m" - memory: 2G + memory: 2G env: - name: JUPYTER_API_KEY - valueFrom: + valueFrom: secretKeyRef: name: jupyterhub-api-key key: jupyterhub-api-key @@ -49,12 +49,13 @@ spec: value: "5000" - name: JUPYTER_API_HOST value: "0.0.0.0" - - name: JNOTE_HOME - value: "/mnt/efs/dsci-100-home/" - - name: JNOTE_SNAP - value: "/mnt/efs/dsci-100-snap/" - - name: JNOTE_INTSNAP - value: "/mnt/efs/dsci-100-internal/" + # optional, to override default values +# - name: JNOTE_HOME +# value: "/mnt/efs/dsci-100-home/" +# - name: JNOTE_SNAP +# value: "/mnt/efs/dsci-100-snap/" +# - name: JNOTE_INTSNAP +# value: "/mnt/efs/dsci-100-internal/" ports: - containerPort: 5000 volumeMounts: