diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b8f99f5be53f536f79ef622abaa77b9942a9e142 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +work diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..26b5d44fc35a6afa584341e0a39f4af1b7334e11 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +ARG BASE_CONTAINER=brunoe/jupyterutln-default +FROM $BASE_CONTAINER + +LABEL maintainer="Emmanuel Bruno <emmanuel.bruno@univ-tln.fr>" + +USER root + +# Install minimal dependencies +RUN apt-get update && apt-get install -y --no-install-recommends\ + coreutils \ + dnsutils \ + gnupg \ + graphviz ttf-bitstream-vera gsfonts \ + inkscape \ + iputils-ping \ + net-tools \ + pandoc \ + procps \ + tree \ + zsh \ + plantuml && \ + apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt + +# Postgresql python library +RUN conda install --quiet --yes psycopg2 && \ + conda install -y -c conda-forge postgresql pgspecial && \ + conda clean -tipsy && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +# SQL support for ipython and PlantUML +RUN pip install ipython-sql iplantuml && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +RUN curl https://kumisystems.dl.sourceforge.net/project/plantuml/plantuml.jar -o /usr/local/bin/plantuml.jar + +ENV PGDATA=/home/jovyan/work/pgdata + +COPY initDB.sh /usr/local/bin/before-notebook.d/ + +RUN pip install jupyterlab_sql && \ + jupyter serverextension enable jupyterlab_sql --py --sys-prefix && \ + jupyter lab build && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +RUN pip install mocodo_magic + +RUN jupyter lab --generate-config && \ + sed -i -e '/c.InteractiveShellApp.extensions = / s/= [^\]]*/= ["mocodo_magic","sql"]/' -e 's/# \(c.InteractiveShellApp.extensions\)/\1/' ~/.ipython/profile_default/ipython_config.py + + +# Switch back to jovyan to avoid accidental container runs as root +USER $NB_UID +RUN mkdir -p /home/jovyan/.ssh && ssh-keyscan -t rsa github.com > /home/jovyan/.ssh/known_hosts +WORKDIR /home/jovyan diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..065a9f9c6cff4aeda64646d32654cc8c2a48e2e8 --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +. ${DIR}/env.sh + +docker build \ + --file Dockerfile \ + -t ${BASE}:$SHA \ + `[[ "$BRANCH" != "master" ]] && echo -t ${BASE}:$BRANCH` \ + `[[ "$BRANCH" == "master" ]] && echo -t ${BASE}:latest` \ + . diff --git a/env.sh b/env.sh new file mode 100755 index 0000000000000000000000000000000000000000..8f244eed68f2b41f13e36051aa72c0d5205ef2bc --- /dev/null +++ b/env.sh @@ -0,0 +1,11 @@ +#!/bin/bash +REGISTRY=brunoe +IMAGE_NAME=${PWD##*/} + +CURRENT=`pwd` +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd $DIR +BASE=${REGISTRY}/${IMAGE_NAME} +BRANCH=`git rev-parse --abbrev-ref HEAD|tr '/' '_' ` +SHA=`git log -1 --pretty=%h` +cd $CURRENT diff --git a/initDB.sh b/initDB.sh new file mode 100755 index 0000000000000000000000000000000000000000..8546fdd7e93ded5b3bffe4f1e98a78ef8680df09 --- /dev/null +++ b/initDB.sh @@ -0,0 +1,5 @@ +DB_NAME=DEMO_DB +rm -rf $PGDATA/$DB_NAME +initdb -D $PGDATA/$DB_NAME +pg_ctl -D $PGDATA/$DB_NAME -l $PGDATA/../$DB_NAME.log start +createdb --owner=jovyan jovyandb \ No newline at end of file diff --git a/push.sh b/push.sh new file mode 100755 index 0000000000000000000000000000000000000000..a62f4e75c9d80048590eb9db5c31be6d484cf3af --- /dev/null +++ b/push.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +echo $DIR +. ${DIR}/env.sh + +BASE=${REGISTRY}/${IMAGE_NAME} +BRANCH=`git rev-parse --abbrev-ref HEAD` + +echo Branche:$BRANCH +docker push ${BASE} --all-tags + diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..0e587df6c79d0950ef743c5227417b9dd2ea56b3 --- /dev/null +++ b/run.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +. ${DIR}/env.sh + +docker run --rm \ + --name ${PWD##*/} \ + --volume $PWD/work:/home/jovyan/work \ + --publish 8888:8888 \ + --env NB_UID=$UID \ + --env JUPYTER_ENABLE_LAB=yes \ + --env GRANT_SUDO=yes \ + --env NB_GID=100 \ + ${BASE}:$SHA + #--env CHOWN_HOME_OPTS='-R' --env CHOWN_HOME=yes \