From 8ea12d62b5103c3aeadfb7bebf4bfbc2dbd6e43c Mon Sep 17 00:00:00 2001 From: Stefano Alberto Russo <stefano.russo@gmail.com> Date: Fri, 24 Jul 2020 12:55:24 +0200 Subject: [PATCH] Added base container using v4.0.16 of official LOFAR software and renamed v3.10 base container folder. --- {base => base_v3}/Dockerfile | 0 {base => base_v3}/build_docker_container.sh | 0 {base => base_v3}/data/input_data/README.md | 0 {base => base_v3}/data/output_data/README.md | 0 {base => base_v3}/entrypoint.sh | 0 {base => base_v3}/run_docker_container.sh | 0 {base => base_v3}/sudoers | 0 base_v4/Dockerfile | 62 ++++++++++++++++++++ base_v4/build_docker_container.sh | 3 + base_v4/data/input_data/README.md | 1 + base_v4/data/output_data/README.md | 1 + base_v4/entrypoint.sh | 53 +++++++++++++++++ base_v4/run_docker_container.sh | 2 + base_v4/sudoers | 30 ++++++++++ 14 files changed, 152 insertions(+) rename {base => base_v3}/Dockerfile (100%) rename {base => base_v3}/build_docker_container.sh (100%) rename {base => base_v3}/data/input_data/README.md (100%) rename {base => base_v3}/data/output_data/README.md (100%) rename {base => base_v3}/entrypoint.sh (100%) rename {base => base_v3}/run_docker_container.sh (100%) rename {base => base_v3}/sudoers (100%) create mode 100644 base_v4/Dockerfile create mode 100755 base_v4/build_docker_container.sh create mode 100644 base_v4/data/input_data/README.md create mode 100644 base_v4/data/output_data/README.md create mode 100644 base_v4/entrypoint.sh create mode 100755 base_v4/run_docker_container.sh create mode 100644 base_v4/sudoers diff --git a/base/Dockerfile b/base_v3/Dockerfile similarity index 100% rename from base/Dockerfile rename to base_v3/Dockerfile diff --git a/base/build_docker_container.sh b/base_v3/build_docker_container.sh similarity index 100% rename from base/build_docker_container.sh rename to base_v3/build_docker_container.sh diff --git a/base/data/input_data/README.md b/base_v3/data/input_data/README.md similarity index 100% rename from base/data/input_data/README.md rename to base_v3/data/input_data/README.md diff --git a/base/data/output_data/README.md b/base_v3/data/output_data/README.md similarity index 100% rename from base/data/output_data/README.md rename to base_v3/data/output_data/README.md diff --git a/base/entrypoint.sh b/base_v3/entrypoint.sh similarity index 100% rename from base/entrypoint.sh rename to base_v3/entrypoint.sh diff --git a/base/run_docker_container.sh b/base_v3/run_docker_container.sh similarity index 100% rename from base/run_docker_container.sh rename to base_v3/run_docker_container.sh diff --git a/base/sudoers b/base_v3/sudoers similarity index 100% rename from base/sudoers rename to base_v3/sudoers diff --git a/base_v4/Dockerfile b/base_v4/Dockerfile new file mode 100644 index 0000000..7150fdf --- /dev/null +++ b/base_v4/Dockerfile @@ -0,0 +1,62 @@ +FROM lofar/lofar-pipeline:LOFAR-Release-4_0_16 + +# Set non-interactive +ENV DEBIAN_FRONTEND noninteractive + +# Always update when extending base images +RUN apt update + + +#------------------------ +# Install deps +#------------------------ + +# Git, Curl, sudo and Nano +RUN apt-get install git curl sudo nano -y + + +#------------------------ +# Lofar user +#------------------------ + +# Add group. We chose GID 65527 to try avoiding conflicts. +RUN groupadd -g 65527 lofar + +# Add user. We chose UID 65527 to try avoiding conflicts. +RUN useradd lofar -d /home/lofar -u 65527 -g 65527 -m -s /bin/bash + +# Add metuaser user to sudoers +RUN adduser lofar sudo + +# No pass sudo (for everyone, actually) +COPY sudoers /etc/sudoers + +# Setup home and input/output data directories +COPY data/input_data /input_data +COPY data/output_data /output_data +RUN chown lofar:lofar /home/lofar && chown -R lofar:lofar /input_data && chown -R lofar:lofar /output_data + +# This is required mainly for Singularity +RUN mv /home/lofar /home/vanilla_lofar +RUN ln -s /tmp/lofarhome /home/lofar +RUN rm -rf /tmp/lofarhome + + +#---------------------- +# Entrypoint +#---------------------- + +# Copy entrypoint +COPY entrypoint.sh / + +# Give right permissions +RUN chmod 755 /entrypoint.sh + +# Set entrypoint +ENTRYPOINT ["/entrypoint.sh"] + +# Set user lofar +USER lofar + +# Set container name +ENV CONTAINER_NAME='base4.0.16' diff --git a/base_v4/build_docker_container.sh b/base_v4/build_docker_container.sh new file mode 100755 index 0000000..f8c627f --- /dev/null +++ b/base_v4/build_docker_container.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build . -t lofarit/base4.0.16 diff --git a/base_v4/data/input_data/README.md b/base_v4/data/input_data/README.md new file mode 100644 index 0000000..2a76678 --- /dev/null +++ b/base_v4/data/input_data/README.md @@ -0,0 +1 @@ +Put here "calib" and "target" MS data (or link agains a folder containing them). diff --git a/base_v4/data/output_data/README.md b/base_v4/data/output_data/README.md new file mode 100644 index 0000000..6056688 --- /dev/null +++ b/base_v4/data/output_data/README.md @@ -0,0 +1 @@ +Directory for output data. diff --git a/base_v4/entrypoint.sh b/base_v4/entrypoint.sh new file mode 100644 index 0000000..f86fb1a --- /dev/null +++ b/base_v4/entrypoint.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Exit on any error. More complex thing could be done in future +# (see https://stackoverflow.com/questions/4381618/exit-a-script-on-error) +set -e + +echo "" +echo "[INFO] Executing entrypoint..." + +#echo "[INFO] Sourcing env in /opt/lofarsoft/lofarinit.sh..." +#source /opt/lofarsoft/lofarinit.sh + +echo "[INFO] Creating /tmp/lofarhome to be used as lofar home" +mkdir /tmp/lofarhome + +echo "[INFO] Initialising /tmp/lofarhome with configuration files" +cp -aT /home/vanilla_lofar /tmp/lofarhome + +echo "[INFO] Moving to /home/lofar and setting as home" +cd /home/lofar +export HOME=/home/lofar + +echo "[INFO] Setting new prompt @$CONTAINER_NAME container" +echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /tmp/lofarhome/.bashrc + +# Set entrypoint command +if [ "x$@" == "x" ]; then + COMMAND="/bin/bash" +else + COMMAND="$@" +fi + + + +# Start! +echo -n "[INFO] Will execute entrypoint command: " +echo $COMMAND +echo "" +echo "==============================================================" +echo "" +echo " Welcome to the LOFAR-IT $CONTAINER_NAME container!" +echo "" +echo "==============================================================" +echo "" +echo "You are now in /home/lofar with write access as user \"$(whoami)\"." +echo "" +echo "Remember that contents inside this container, unless stored" +echo "on a persistent volume mounted from you host machine, will" +echo "be wiped out when exiting the container." +echo "" + +exec $COMMAND + diff --git a/base_v4/run_docker_container.sh b/base_v4/run_docker_container.sh new file mode 100755 index 0000000..a240bcc --- /dev/null +++ b/base_v4/run_docker_container.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker run --rm -v $PWD/data:/data -it lofarit/base4.0.16 /bin/bash diff --git a/base_v4/sudoers b/base_v4/sudoers new file mode 100644 index 0000000..47ab37c --- /dev/null +++ b/base_v4/sudoers @@ -0,0 +1,30 @@ +# +# This file MUST be edited with the 'visudo' command as root. +# +# Please consider adding local content in /etc/sudoers.d/ instead of +# directly modifying this file. +# +# See the man page for details on how to write a sudoers file. +# +Defaults env_reset +Defaults mail_badpass +Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# Host alias specification + +# User alias specification + +# Cmnd alias specification + +# User privilege specification +root ALL=(ALL:ALL) ALL + +# Members of the admin group may gain root privileges +%admin ALL=(ALL) ALL + +# Allow members of group sudo to execute any command +%sudo ALL=(ALL:ALL) NOPASSWD:ALL + +# See sudoers(5) for more information on "#include" directives: + +#includedir /etc/sudoers.d -- GitLab