diff options
author | Suren A. Chilingaryan <csa@ipecompute2.ands.kit.edu> | 2020-11-11 06:30:49 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@ipecompute2.ands.kit.edu> | 2020-11-11 06:30:49 +0100 |
commit | 4db96282d126e10c691474264fcdbeca2398555e (patch) | |
tree | 0c5e6991e532e4716db7372ab9e63adbc5a3284d | |
parent | b363c63d44eef05a06f8f7ff7c471ac4392cc4e9 (diff) | |
download | ccpi-4db96282d126e10c691474264fcdbeca2398555e.tar.gz ccpi-4db96282d126e10c691474264fcdbeca2398555e.tar.bz2 ccpi-4db96282d126e10c691474264fcdbeca2398555e.tar.xz ccpi-4db96282d126e10c691474264fcdbeca2398555e.zip |
Add supervisord to run ssh and jupyter in parallel
-rw-r--r-- | build/buildah-remote.sh | 21 | ||||
-rw-r--r-- | run/run-bash.sh | 7 | ||||
-rw-r--r-- | run/run.sh | 2 |
3 files changed, 29 insertions, 1 deletions
diff --git a/build/buildah-remote.sh b/build/buildah-remote.sh index 1016d19..5e9d038 100644 --- a/build/buildah-remote.sh +++ b/build/buildah-remote.sh @@ -8,6 +8,9 @@ image="$1" container=$(buildah from ${image}:latest) buildah config --port 2222/tcp --port 8888/tcp $container +buildah run $container sh -c 'apt-get install -y supervisor' + + buildah run $container sh -c "echo '$(id -ng):x:$(id -g):' >> /etc/group" #buildah run $container sh -c "echo '$(id -nu):x:$(id -u):$(id -g):$(id -nu):/ccpi/data:/bin/bash' >> /etc/passwd" buildah run $container sh -c "echo '$(id -nu):x:0:0:$(id -nu):/ccpi/data:/bin/bash' >> /etc/passwd" @@ -15,6 +18,24 @@ buildah run $container sh -c "echo '$(id -nu):x:0:0:$(id -nu):/ccpi/data:/bin/ba buildah run $container sh -c 'service ssh start' buildah run $container sh -c "echo '$(id -nu):test' | chpasswd" +buildah run $container sh -c 'cat <<EOF >/etc/supervisord.conf +[supervisord] +nodaemon=false + +[program:sshd] +command=/usr/sbin/sshd -D -p 2222 +autorestart=true +startsecs=2 +exitcodes=0 + +[program:jupyter] +command=jupyter notebook --allow-root --no-browser --ip 0.0.0.0 --port=8888 --notebook-dir=/ccpi/data/ +autorestart=true +startsecs=5 +exitcodes=0 +EOF +' + buildah commit --format docker $container ${image}-remote:latest echo "$container build from ${image} and saved as ${image}-remote" diff --git a/run/run-bash.sh b/run/run-bash.sh new file mode 100644 index 0000000..bdfade3 --- /dev/null +++ b/run/run-bash.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +set -o errexit + +. config.sh + +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp -p $ssh_port:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/${image} bash @@ -4,4 +4,4 @@ set -o errexit . config.sh -podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp -p $ssh_port:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/${image} bash +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp -p $ssh_port:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/${image} sh -c '[ -f /usr/bin/supervisord ] && python2 /usr/bin/supervisord; /bin/bash' |