summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatin Dehghani <matin@ipecompute4.ands.kit.edu>2022-06-26 01:07:34 +0200
committerMatin Dehghani <matin@ipecompute4.ands.kit.edu>2022-06-26 01:07:34 +0200
commitf33bcbf3c0839c6bebb63141ff3d520b41084183 (patch)
tree6b373e8e123607755940b6ae3cc8076f5977a145
parentd4f8c2c238342bf3adfa236c49ff43eecd018201 (diff)
downloadccpi-f33bcbf3c0839c6bebb63141ff3d520b41084183.tar.gz
ccpi-f33bcbf3c0839c6bebb63141ff3d520b41084183.tar.bz2
ccpi-f33bcbf3c0839c6bebb63141ff3d520b41084183.tar.xz
ccpi-f33bcbf3c0839c6bebb63141ff3d520b41084183.zip
More fine-grained image management (e.g. allow to get prebuilt images from other user and adapt ids inside with change-user.sh script)
-rw-r--r--build/change-user.sh15
-rw-r--r--build/extract.sh2
-rw-r--r--run/config.sh2
-rw-r--r--run/devel.sh2
-rw-r--r--run/run-bash.sh2
-rw-r--r--run/run-jupyter.sh2
-rw-r--r--run/run-ssh.sh2
-rw-r--r--run/run.sh2
-rw-r--r--run/update-from-devel.sh2
9 files changed, 23 insertions, 8 deletions
diff --git a/build/change-user.sh b/build/change-user.sh
new file mode 100644
index 0000000..cb13141
--- /dev/null
+++ b/build/change-user.sh
@@ -0,0 +1,15 @@
+#! /usr/bin/env bash
+
+set -o errexit
+
+image="$1"
+[ -n "$image" ] || image="docker.io/chsa/tomo-remote:evelina"
+
+container=$(buildah from "$image")
+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"
+buildah run $container sh -c "echo '$(id -nu):test' | chpasswd"
+buildah commit --format docker $container tomo-remote:latest
+
+echo "$container build from ${image} and saved as tomo-remote:latest"
diff --git a/build/extract.sh b/build/extract.sh
index 17c6e3f..90793d5 100644
--- a/build/extract.sh
+++ b/build/extract.sh
@@ -6,7 +6,7 @@ image="$1"
[ -n "$image" ] || { echo "Usage: $0 <astra|ccpi|ufo|tomo|imageX>"; exit 1; }
-container=$(buildah from localhost/${image})
+container=$(buildah from ${image})
path=$(buildah mount $container)
mkdir -p ../repos/
cp -ra "$path/ccpi/repos"/* ../repos/
diff --git a/run/config.sh b/run/config.sh
index f3bdecb..b407fef 100644
--- a/run/config.sh
+++ b/run/config.sh
@@ -6,7 +6,7 @@ web_port="${port}80"
image="$1"
-[ -n "$image" ] || image="tomo-remote" # tomo-remote:latest tomo-remote:devel (also ccpi, ufo, tomo)
+[ -n "$image" ] || image="localhost/tomo-remote:latest" # tomo-remote:latest tomo-remote:devel tomo-remote:evelina (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"
diff --git a/run/devel.sh b/run/devel.sh
index 637552a..fef44e0 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 $volumes 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 ${image} bash -c "[ -f /usr/bin/supervisord ] && python /usr/bin/supervisord; bash /root/setup/provision.sh; bash"
diff --git a/run/run-bash.sh b/run/run-bash.sh
index 41c2579..1e25e8a 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 $volumes 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 ${image} bash
diff --git a/run/run-jupyter.sh b/run/run-jupyter.sh
index 31d819d..3858b4e 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 $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
+podman run --name "ccpi-run" -it --rm --hooks-dir /usr/share/containers/oci/hooks.d/ -p ${web_port}:8888/tcp $volumes ${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 8e3dfdb..86f994f 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 $volumes 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 ${image} /usr/sbin/sshd -D -p 2222
diff --git a/run/run.sh b/run/run.sh
index eae1cec..eabb633 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 $volumes localhost/${image} sh -c '[ -f /usr/bin/supervisord ] && python /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 ${image} sh -c '[ -f /usr/bin/supervisord ] && python /usr/bin/supervisord; /bin/bash'
diff --git a/run/update-from-devel.sh b/run/update-from-devel.sh
index 4eb8e7b..2be835f 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/ $volumes localhost/${image} bash /root/setup/provision.sh
+podman run --name "ccpi-devel" -it --hooks-dir /usr/share/containers/oci/hooks.d/ $volumes ${image} bash /root/setup/provision.sh
podman container cp ../repos/ ccpi-devel:/ccpi/
podman container commit ccpi-devel ${image}:devel
podman rm ccpi-devel