diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 3c83313d..bc71897e 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -36,6 +36,11 @@ RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 # install git-lfs RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && sudo apt-get install git-lfs=2.8.0 +# Add Tini +ENV TINI_VERSION v0.18.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini + # switch to the notebook user USER $NB_USER @@ -71,4 +76,7 @@ RUN echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ rm -rf /wheels USER $NB_USER +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT [ "/tini", "--", "/entrypoint.sh" ] + CMD '/usr/local/bin/start-singleuser.sh' diff --git a/docker/base/entrypoint.sh b/docker/base/entrypoint.sh new file mode 100755 index 00000000..9a1ff22b --- /dev/null +++ b/docker/base/entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Setup git user +if [ -z "$(git config --global --get user.name)" ]; then + git config --global user.name "$GIT_AUTHOR_NAME" +fi +if [ -z "$(git config --global --get user.email)" ]; then + git config --global user.email "$EMAIL" +fi + +# +# copy the environment from renku-env repo +# + +# clone the repo +proto=$(echo $GITLAB_URL | sed -e's,^\(.*://\).*,\1,g') +url=$(echo ${GITLAB_URL/$proto/}) +user=$(echo ${CI_REPOSITORY_URL/$proto/} | grep @ | cut -d@ -f1) + +git clone --depth 1 ${proto}${user}@${url}/${JUPYTERHUB_USER}/renku-env.git /tmp/renku-env || true + +# append the contents of all the files to same files in ${HOME} +find /tmp/renku-env -not -path '*.git*' -type f -print0 | xargs --null -I{} sh -c 'cat {} >> ${HOME}/$(basename "{}")' || true + +# run the command +$@ diff --git a/docker/r/entrypoint.sh b/docker/r/entrypoint.sh index dc884771..9fc1e666 100755 --- a/docker/r/entrypoint.sh +++ b/docker/r/entrypoint.sh @@ -19,6 +19,19 @@ fi # add a symlink to the project directory in /home/rstudio [ -n "$CI_PROJECT" ] && ln -s /work/${CI_PROJECT} /home/rstudio +# +# copy the environment from renku-env repo +# + +# clone the repo +proto=$(echo $GITLAB_URL | sed -e's,^\(.*://\).*,\1,g') +url=$(echo ${GITLAB_URL/$proto/}) +user=$(echo ${CI_REPOSITORY_URL/$proto/} | grep @ | cut -d@ -f1) + +git clone --depth 1 ${proto}${user}@${url}/${JUPYTERHUB_USER}/renku-env.git /tmp/renku-env || true + +# append the contents of all the files to same files in ${HOME} +find /tmp/renku-env -not -path '*.git*' -type f -print0 | xargs --null -I{} sh -c 'cat {} >> ${HOME}/$(basename "{}")' || true # run the command $@