From d4f8c2c238342bf3adfa236c49ff43eecd018201 Mon Sep 17 00:00:00 2001 From: Evelina Ametova Date: Sun, 29 May 2022 17:03:27 +0200 Subject: Configure volumes and support 'fast' storage --- run/config.sh | 6 ++++++ run/devel.sh | 2 +- run/run-bash.sh | 2 +- run/run-jupyter.sh | 2 +- run/run-ssh.sh | 2 +- run/run.sh | 2 +- run/test.sh | 2 +- run/update-from-devel.sh | 2 +- 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/run/config.sh b/run/config.sh index 048ecfb..f3bdecb 100644 --- a/run/config.sh +++ b/run/config.sh @@ -1,8 +1,14 @@ +user="$(id -un)" +home="/home/$user" port="$(($(id -u)%100 + 100))" ssh_port="${port}22" web_port="${port}80" + image="$1" [ -n "$image" ] || image="tomo-remote" # tomo-remote:latest tomo-remote:devel (also ccpi, ufo, tomo) +volumes="-v $home/ccpi/data:/ccpi/data -v $home/ccpi/repos:/ccpi/repos" +[ -d /mnt/fast/$user ] && volumes="$volumes -v /mnt/fast/$user:/ccpi/data/fast" + echo "Image: $image, Ports: $ssh_port, $web_port" diff --git a/run/devel.sh b/run/devel.sh index a15f203..637552a 100644 --- a/run/devel.sh +++ b/run/devel.sh @@ -8,4 +8,4 @@ if [ ! -d ../repos ]; then buildah unshare bash ../build/extract.sh ${image} fi -podman run --name "ccpi-devel" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p $ssh_port:2222/tcp -v ~/ccpi/data:/ccpi/data -v ~/ccpi/repos:/ccpi/repos localhost/${image} bash -c "bash /root/setup/provision.sh; bash" +podman run --name "ccpi-devel" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p $ssh_port:2222/tcp $volumes localhost/${image} bash -c "bash /root/setup/provision.sh; bash" diff --git a/run/run-bash.sh b/run/run-bash.sh index bdfade3..41c2579 100644 --- a/run/run-bash.sh +++ b/run/run-bash.sh @@ -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 $volumes localhost/${image} bash diff --git a/run/run-jupyter.sh b/run/run-jupyter.sh index f596a2b..31d819d 100644 --- a/run/run-jupyter.sh +++ b/run/run-jupyter.sh @@ -10,4 +10,4 @@ echo " ssh -L $web_port:localhost:$web_port $(hostname)" echo "Generate password file '/ccpi/data/.jupyter/jupyter_notebook_config.json' with running in the container the following command" echo " jupyter notebook password" -podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp -v ~/ccpi/data:/ccpi/data localhost/${image} jupyter notebook --allow-root --no-browser --ip 0.0.0.0 --port=8888 --notebook-dir=/ccpi/data/ --debug \ No newline at end of file +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp $volumes localhost/${image} jupyter notebook --allow-root --no-browser --ip 0.0.0.0 --port=8888 --notebook-dir=/ccpi/data/ --debug \ No newline at end of file diff --git a/run/run-ssh.sh b/run/run-ssh.sh index c467334..8e3dfdb 100644 --- a/run/run-ssh.sh +++ b/run/run-ssh.sh @@ -10,4 +10,4 @@ echo " ssh -L $ssh_port:localhost:$ssh_port $(hostname)" echo " and connect locally " echo " ssh -p $ssh_port localhost" -podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${ssh_port}:2222/tcp -v ~/ccpi/data:/ccpi/data localhost/${image} /usr/sbin/sshd -D -p 2222 +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${ssh_port}:2222/tcp $volumes localhost/${image} /usr/sbin/sshd -D -p 2222 diff --git a/run/run.sh b/run/run.sh index 55b5b21..eae1cec 100644 --- a/run/run.sh +++ b/run/run.sh @@ -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} sh -c '[ -f /usr/bin/supervisord ] && python2 /usr/bin/supervisord; /bin/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 $volumes localhost/${image} sh -c '[ -f /usr/bin/supervisord ] && python /usr/bin/supervisord; /bin/bash' diff --git a/run/test.sh b/run/test.sh index 90624c0..97bb631 100644 --- a/run/test.sh +++ b/run/test.sh @@ -3,4 +3,4 @@ set -o errexit #podman exec -it "ccpi-devel" bash /ccpi/data/run.sh -podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -v ~/ccpi/data:/ccpi/data -e "CUDA_VISIBLE_DEVICES=2" localhost/ccpi:devel bash /ccpi/data/run.sh +podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ $volumes -e "CUDA_VISIBLE_DEVICES=2" localhost/ccpi:devel bash /ccpi/data/run.sh diff --git a/run/update-from-devel.sh b/run/update-from-devel.sh index b2a8b25..4eb8e7b 100644 --- a/run/update-from-devel.sh +++ b/run/update-from-devel.sh @@ -8,7 +8,7 @@ if [ ! -d ../repos ]; then buildah unshare bash ../build/extract.sh ${image} fi -podman run --name "ccpi-devel" -it --hooks-dir /usr/share/containers/oci/hooks.d/ -v ~/ccpi/data:/ccpi/data -v ~/ccpi/repos:/ccpi/repos localhost/${image} bash /root/setup/provision.sh +podman run --name "ccpi-devel" -it --hooks-dir /usr/share/containers/oci/hooks.d/ $volumes localhost/${image} bash /root/setup/provision.sh podman container cp ../repos/ ccpi-devel:/ccpi/ podman container commit ccpi-devel ${image}:devel podman rm ccpi-devel -- cgit v1.2.1