Skip to content

Commit

Permalink
feat: added pre-stop pod lifecycle script
Browse files Browse the repository at this point in the history
  • Loading branch information
jachro authored and rokroskar committed Apr 12, 2019
1 parent a9b50dc commit 2a32302
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ RUN pipx install ${RENKU_PIP_SPEC} --pip-args="--pre" renku && \
COPY git-config.bashrc /home/$NB_USER/
RUN cat /home/$NB_USER/git-config.bashrc >> /home/$NB_USER/.bashrc && rm /home/$NB_USER/git-config.bashrc

COPY lifecycle/ /usr/local/bin/

# Add user `jovyan` to sudoers (passwordless)
USER root
RUN echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
Expand Down
16 changes: 16 additions & 0 deletions docker/base/lifecycle/pre-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

GIT_STATUS=`git status -s`
if [ -z "$GIT_STATUS" ] ; then
exit 0
fi

CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
CURRENT_SHA=`git rev-parse --short HEAD`
AUTOSAVE_BRANCH="renku/autosave/$JUPYTERHUB_USER/${CURRENT_BRANCH}/${CURRENT_SHA}"
git checkout -b "$AUTOSAVE_BRANCH"
git add .
git commit -am "Auto-saving for $JUPYTERHUB_USER on branch $CURRENT_BRANCH and commit $CURRENT_SHA"
git push origin "$AUTOSAVE_BRANCH"
git checkout master
git branch -D "$AUTOSAVE_BRANCH"

0 comments on commit 2a32302

Please sign in to comment.