Skip to content
Snippets Groups Projects
Commit 1e1c1760 authored by Giuliano Taffoni's avatar Giuliano Taffoni
Browse files

First Commit

parents
No related branches found
No related tags found
No related merge requests found
FROM centos:7
MAINTAINER Giuliano Taffoni <giuliano.taffoni@inaf.it>
ENV CONTAINER_NAME='ALMAGAL'
USER root
#
# Set enviroment
#
ARG J=2
ARG INSTALL_DIR=/opt/
ARG CASARELEASE="casa-pipeline-release-5.6.1-8.el7.tar.gz"
# Settings relevant to the installed software.
ENV CASAVERSION="5.6.1-8"
ENV CASABIN="/opt/casa-pipeline-release-5.6.1-8.el7/bin"
ENV DEBIAN_FRONTEND=noninteractive
#
# System installs
#
RUN yum -y update && yum -y upgrade
# remove automatic updates and warnings
#
RUN yum -y install gcc g++ gfortran git make cmake wget sudo
RUN yum -y install freetype libX11 libXft vim-enhanced libGL libSM libXext libXrandr libXi libXcursor libXinerama
RUN cd /tmp/ && wget https://casa.nrao.edu/download/distro/casa-pipeline/release/el7/${CASARELEASE}
RUN tar zxvf /tmp/${CASARELEASE} -C /opt/
RUN rm -f /tmp/${CASARELEASE}
# Add group. We chose GID 65527 to try avoiding conflicts.
RUN groupadd -g 65527 metagroup
# Add user. We chose UID 65527 to try avoiding conflicts.
RUN useradd metauser -d /home/metauser -u 65527 -g 65527 -m -s /bin/bash
# Add metuaser user to sudoers
RUN echo "metauser ALL=(ALL)NOPASSWD: ALL" >> /etc/sudoers
# update PATH
RUN echo "PATH=${CASABIN}:\$PATH" >> /home/metauser/.bash_profile
RUN mkdir /home/metauser/.casa
COPY files/init.py /home/metauser/.casa
COPY files/analysis_scripts_sing.tgz /home/metauser/
RUN cd /home/metauser && tar zxvf /home/metauser/analysis_scripts_sing.tgz
# Prepare to make a clean enviroment to share with SINGULARITY
RUN mv /home/metauser /metauser_home_vanilla
RUN chmod 777 /metauser_home_vanilla
# Give write access to anyone to the home folder so the entrypoint will be able
# to copy over the /home/matauser_vanilla into /home/skauser (for Singularity)
RUN chmod 777 /home
RUN for i in `ls ${CASABIN}/`; do ln -s ${CASABIN}/${i} /usr/local/bin/; done
#----------------------
# Entrypoint
#----------------------
# Copy entrypoint
COPY entrypoint.sh /
# Give right permissions
RUN chmod 755 /entrypoint.sh
# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]
USER metauser
#!/bin/bash
if [ "x$TAG" == "x"]; then
TAG=latest
if
docker build -t morgan1971/almagal:$TAG -f Dockerfile.base .
#!/bin/bash
# Exit on any error. More complex stuff could be done in future
# (see https://stackoverflow.com/questions/4381618/exit-a-script-on-error)
set -e
if [ "x$SAFE_MODE" == "xTrue" ]; then
echo ""
echo "[INFO] Not executing entrypoint as we are in safe mode, just opening a Bash shell."
exec /bin/bash
else
echo ""
echo "[INFO] Executing entrypoint..."
#---------------------
# Setup home
#---------------------
if [ ! -f "/home/metauser/.initialized" ]; then
echo "[INFO] Setting up home"
[ ! -d "/home/metauser" ] && mkdir -p /home/metauser
# Copy over vanilla home contents
if [ "x$DEBUG" == "xTrue" ] ; then
ls -la /home/metauser
ls -la /metauser_home_vanilla/
fi
for x in /metauser_home_vanilla/* /metauser_home_vanilla/.[!.]* /metauser_home_vanilla/..?*; do
if [ -e "$x" ]; then cp -a "$x" /home/metauser/; fi
done
if [ "x$DEBUG" == "xTrue" ] ; then
ls -la /home/metauser
fi
# Mark as initialized
[ ! -f "/home/metauser/.initialized" ] && touch /home/metauser/.initialized
fi
#---------------------
# Save env
#---------------------
echo "[INFO] Dumping env"
# Save env vars for later usage (e.g. ssh)
env | \
while read env_var; do
if [[ $env_var == HOME\=* ]]; then
: # Skip HOME var
elif [[ $env_var == PWD\=* ]]; then
: # Skip PWD var
else
echo "export $env_var" >> /tmp/env.sh
fi
done
echo "[INFO] Moving to /home/metauser and setting as home"
cd /home/metauser
export HOME=/home/metauser
echo "[INFO] Setting new prompt @$CONTAINER_NAME container"
echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /home/metauser/.bash_profile
source /home/metauser/.bash_profile
# Set entrypoint command
if [ "x$@" == "x" ]; then
# Start!
echo -n "[INFO] Will execute entrypoint command: "
echo ""
echo "=============================================================="
echo ""
echo " Welcome to the EUROEXA $CONTAINER_NAME container!"
echo ""
echo "=============================================================="
echo ""
echo "You are now in /home/skauser 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 ""
COMMAND="/bin/bash"
else
COMMAND="$@"
fi
fi
exec $COMMAND
File added
import sys
sys.path.append("/usr/lib/python2.7/site-packages")
sys.path.append("/usr/lib64/python2.7/site-packages")
sys.path.append("/home/metauser/analysis_scripts/")
import analysisUtils as aU
#!/bin/bash
#
# This Script allows to execute the conatiner using singularity
# in an isolated enviroment
#
# author <giuliano.taffoni@inaf.it>
#
if [ 'XXX'$1 = 'XXX' ]; then
COMMAND=/bin/bash
else
COMMAND=$1
fi
CONTAINER_NAME="morgan1971/almagal"
CONTAINER_VERSION="v0.1.0"
export BASE_PORT=
export SINGULARITYENV_BASE_PORT=$BASE_PORT
export CONTAINER_NAME="docker://${CONTAINER_NAME}:${CONTAINER_VERSION}"
HOMEDIR=`mktemp -d -t singularity_XXXXXXX`
mkdir $HOMEDIR/tmp
mkdir $HOMEDIR/home
export FLAGS="--pid --writable-tmpfs --no-home --home=/home/metauser --workdir ${HOMEDIR}/tmp -B${HOMEDIR}:/home/ --containall --cleanenv"
singularity run $FLAGS ${CONTAINER_NAME} $COMMAND
rm -fr ${HOMEDIR}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment