Skip to content
Snippets Groups Projects
Commit f5d8ba5a authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

added singularity imgw scripts, updated base

parent 1d65e712
No related branches found
No related tags found
No related merge requests found
Showing
with 466 additions and 62 deletions
Bootstrap: docker
From: almalinux:8
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
# command prompt name
CNAME=alma8.base
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%environment
export LANG=C.UTF-8
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/include
\ No newline at end of file
Bootstrap: docker
From: almalinux:8
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
# Every line will be a layer in the container
# See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools
yum update -y \
&& yum install -y dnf-plugins-core \
&& dnf config-manager --set-enabled powertools \
&& yum install -y epel-release \
&& yum update -y \
&& yum --enablerepo epel groupinstall -y "Development Tools" \
&& yum --enablerepo epel install -y \
curl \
findutils \
gcc-c++ \
gcc \
gcc-gfortran \
git \
gnupg2 \
hostname \
iproute \
make \
patch \
python38 \
python38-pip \
python38-setuptools \
unzip \
nco \
hdf5-devel \
netcdf-devel \
netcdf-fortran-devel \
python38-numpy-f2py \
&& rm -rf /var/cache/yum \
&& yum clean all
# This means no openmpi
# command prompt name
CNAME=alma8.met
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%environment
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/lib64/gfortran/modules:/usr/include
Bootstrap: docker
From: almalinux:8
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
# Every line will be a layer in the container
# See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools
yum update -y \
&& yum install -y dnf-plugins-core \
&& dnf config-manager --set-enabled powertools \
&& yum install -y epel-release \
&& yum update -y \
&& yum --enablerepo epel groupinstall -y "Development Tools" \
&& yum --enablerepo epel install -y \
curl \
findutils \
gcc-c++ \
gcc \
gcc-gfortran \
git \
gnupg2 \
hostname \
iproute \
make \
patch \
python38 \
python38-pip \
python38-setuptools \
unzip \
nco \
hdf5-openmpi-devel \
netcdf-openmpi-devel \
netcdf-fortran-openmpi-devel \
python38-numpy-f2py \
&& rm -rf /var/cache/yum \
&& yum clean all
# This means no openmpi
# command prompt name
CNAME=alma8.metompi
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%environment
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/lib64/gfortran/modules:/usr/include
Bootstrap: docker
From: almalinux:8
#
# This is a spack development image to use for downstream development
# to be combined with the base image for two stage builds
#
%labels
MAINTAINER Spack Maintainers <maintainers@spack.io>
......@@ -68,6 +73,7 @@ From: almalinux:8
export DEBIAN_FRONTEND=noninteractive
%runscript
# Need spack entry point to allow spack builds
exec /bin/bash /opt/spack/share/spack/docker/entrypoint.bash interactive-shell "$@"
%startscript
......
Bootstrap: docker
From: alpine
%labels
MAINTAINER Michael Blaschek <michael.blaschek@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
apk add --no-cache build-base \
curl \
gcc \
gcc-gfortran \
make \
cdo \
nco \
hdf5-dev \
hdf5-fortran \
netcdf-dev \
netcdf-fortran
# command prompt name
CNAME=u18.04.base
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%environment
export LANG=C.UTF-8
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/include
\ No newline at end of file
Bootstrap: docker
From: mambaorg/micromamba:latest
%help
Micromamba conda environment with
Python 3.9.13 and the latest eccodes (binary+py)
https://pypi.org/project/eccodes/
%labels
maintainer M. Blaschek
mail michael.blaschek@univie.ac.at
date 7.10.2022
python 3.9.13
eccodes 2.27.0
gcc 9.5.0
gfortran 9.5.0
%post
micromamba -q install -y -n base -c conda-forge eccodes=2.27.0 cdo nco netcdf4 hdf5 openmpi=4.0.5 gcc=9.5.0 gfortran=9.5.0 python=3.9.13 &&
/opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge &&
micromamba clean --all --yes
%environment
LIBRARY=/opt/conda/lib
INCLUDE=/opt/conda/include
BIN=/opt/conda/bin
SHARE=/opt/conda/share
%test
/opt/conda/bin/python3 -m eccodes selfcheck
Bootstrap: docker
From: mambaorg/micromamba:latest
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
apt -y update && apt -y install \
build-essential \
git \
tcsh \
csh \
ksh \
m4 \
libtool \
automake \
autoconf \
&& apt -y clean
micromamba -q install -y -n base -c conda-forge \
eccodes=2.27.0 \
cdo \
nco \
netcdf4 \
hdf5 \
openmpi=4.0.5 \
gcc=9.5.0 \
gfortran=9.5.0 \
python=3.9.13 &&
/opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge &&
micromamba clean --all --yes
# command prompt name
CNAME=m.dart
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%test
python -m eccodes selfcheck
gfortran --version
gcc --version
ncks --version
cdo --version
%environment
export PATH=/opt/conda/bin:$PATH
export LIBRARY=/opt/conda/lib:/usr/lib64:/lib64:/lib
export INCLUDE=/opt/conda/include:/usr/include
Bootstrap: docker
From: mambaorg/micromamba:latest
%help
Micromamba conda environment with
Python 3.9.13 and the latest eccodes (binary+py)
https://pypi.org/project/eccodes/
%labels
maintainer M. Blaschek
mail michael.blaschek@univie.ac.at
date 7.10.2022
maintainer IT-IMGW <it.img-wien@univie.ac.at>
python 3.9.13
eccodes 2.27.0
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%post
micromamba -q install -y -n base -c conda-forge eccodes=2.27.0 python=3.9.13 &&
/opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge &&
micromamba clean --all --yes
# command prompt name
CNAME=m.eccodes
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%test
python -m eccodes selfcheck
%environment
export PATH=/opt/conda/bin:$PATH
export LIBRARY=/opt/conda/lib
export INCLUDE=/opt/conda/include
\ No newline at end of file
Bootstrap: docker
From: mambaorg/micromamba:latest
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%files
$PWD/definition-files/runscript /.singularity.d/runscript
$PWD/definition-files/run-help /.singularity.d/runscript.help
%apprun install-ipykernel
# install current container as kernel
mkdir -p $HOME/.local/share/jupyter/kernels/metdev-py3
cat <<EOF >$HOME/.local/share/jupyter/kernels/metdev-py3/kernel.json
{
"language": "python",
"argv": ["singularity",
"exec",
"$SINGULARITY_CONTAINER",
"/opt/conda/bin/python3",
"-m",
"ipykernel",
"-f",
"{connection_file}"
],
"display_name": "sPy 3 (metdev)"
}
EOF
echo "Kernel written: $HOME/.local/share/jupyter/kernels/metdev-py3"
%post
micromamba -q install -y -n base -c conda-forge \
python=3.9.13 \
eccodes=2.27.0 \
ipykernel \
nco \
cdo \
pandas \
xarray \
dask \
numba \
scipy \
netcdf4 \
h5py \
hdf5 \
distributed \
proj \
h5netcdf \
matplotlib \
zarr \
metpy \
cartopy \
&& /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge &&
micromamba clean --all --yes
# command prompt name
CNAME=m.metdev
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
# add App help information
echo -e "Apps: \n- install-ipykernel Install IPython Kernel to local user\n" >> /.singularity.d/runscript.help
%test
# Check eccodes lib functionality
python -m eccodes selfcheck
# Check cartopy
# Check netcdf
# Check hdf5
%environment
export LANG=C.UTF-8
export PATH=/opt/conda/bin:$PATH
export LIBRARY=/opt/conda/lib
export INCLUDE=/opt/conda/include
\ No newline at end of file
Singularity/Apptainer container
(c) Department of Meteorology and Geophysics
University of Vienna
interactive shell
> singularity shell image.sif
> ./image.sif
run a command inside the container
> ./image.sif [cmd] [args]
bind special directories
> export SINGULARITY_BIND=/this/is/not/a/typical/linux/path
> ./image.sif ls /this/is/not/a/typical/linux/path
development using includes and libraries from inside the container
> ./image.sif gfortran -I\$INCLUDE -L\$LIBRARY -o test.x test.f90
Ask for help: it.img-wien@univie.ac.at
Gitlab: https://gitlab.phaidra.org/imgw/singularity
#!/bin/sh
# overwrite any existing runscript
# add IMGW customized PROMPT_COMMAND
if [ $# -gt 0 ]; then
# run cmd line options
exec "$@"
else
# interactive
echo "Welcome inside an IMGW container!"
echo "Get help: singularity run-help $SINGULARITY_NAME"
exec /.singularity.d/actions/shell "$@"
fi
\ No newline at end of file
......@@ -3,20 +3,9 @@ MirrorURL: http://at.archive.ubuntu.com/ubuntu
OSVersion: bionic
%labels
APPLICATION_NAME ubuntu
APPLICATION_VERSION 18.04
APPLICATION_URL https://www.ubuntu.com
AUTHOR_NAME Michael Blaschek
AUTHOR_EMAIL michael.blaschek@univie.ac.at
LAST_UPDATED 20211118
%setup
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%environment
# Set operating system mirror URL
export MIRRORURL='http://at.archive.ubuntu.com/ubuntu'
......@@ -24,7 +13,8 @@ OSVersion: bionic
export OSVERSION='bionic'
# Set system locale
export LC_ALL='C'
#export LC_ALL='C'
export LANG=C.UTF-8
# Set debian frontend interface
export DEBIAN_FRONTEND='noninteractive'
......@@ -38,7 +28,8 @@ OSVersion: bionic
export OSVERSION='bionic'
# Set system locale
export LC_ALL=C
# export LC_ALL=C
export LANG=C.UTF-8
# Set debian frontend interface
export DEBIAN_FRONTEND='noninteractive'
......@@ -91,9 +82,15 @@ OSVersion: bionic
# Update database for mlocate
updatedb
# command prompt name
CNAME=u18.04.base
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%files
%runscript
%test
%environment
export LANG=C.UTF-8
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/include
\ No newline at end of file
......@@ -2,18 +2,10 @@ Bootstrap: debootstrap
MirrorURL: http://at.archive.ubuntu.com/ubuntu
OSVersion: focal
%labels
APPLICATION_NAME ubuntu
APPLICATION_VERSION 20.04
APPLICATION_URL https://www.ubuntu.com
AUTHOR_NAME Michael Blaschek
AUTHOR_EMAIL michael.blaschek@univie.ac.at
LAST_UPDATED 20211118
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%setup
%environment
......@@ -24,7 +16,8 @@ OSVersion: focal
export OSVERSION='focal'
# Set system locale
export LC_ALL='C'
#export LC_ALL='C'
export LANG=C.UTF-8
# Set debian frontend interface
export DEBIAN_FRONTEND='noninteractive'
......@@ -38,7 +31,8 @@ OSVersion: focal
export OSVERSION='focal'
# Set system locale
export LC_ALL=C
#export LC_ALL=C
export LANG=C.UTF-8
# Set debian frontend interface
export DEBIAN_FRONTEND='noninteractive'
......@@ -91,9 +85,15 @@ OSVersion: focal
# Update database for mlocate
updatedb
# command prompt name
CNAME=u20.04.base
# does not work goes into /.singularity.d/env/91-environment.sh
echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh
# add some labels
echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS"
echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS"
%files
%runscript
%test
%environment
export LANG=C.UTF-8
export LIBRARY=/usr/lib64:/lib64:/lib
export INCLUDE=/usr/include
\ No newline at end of file
Bootstrap: docker
From: ubuntu:18.04
%labels
maintainer IT-IMGW <it.img-wien@univie.ac.at>
%environment
# Point to OMPI binaries, libraries, man pages
export OMPI_DIR=/opt/ompi
export PATH="$OMPI_DIR/bin:$PATH"
export LD_LIBRARY_PATH="$OMPI_DIR/lib:$LD_LIBRARY_PATH"
export MANPATH="$OMPI_DIR/share/man:$MANPATH"
export LANG=C.UTF-8
%post
echo "Installing required packages..."
apt-get update && apt-get install -y wget git bash gcc gfortran g++ make file
echo "Installing Open MPI"
export OMPI_DIR=/opt/ompi
export OMPI_VERSION=4.0.5
export OMPI_URL="https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-$OMPI_VERSION.tar.bz2"
mkdir -p /tmp/ompi
mkdir -p /opt
# Download
cd /tmp/ompi && wget -O openmpi-$OMPI_VERSION.tar.bz2 $OMPI_URL && tar -xjf openmpi-$OMPI_VERSION.tar.bz2
# Compile and install
cd /tmp/ompi/openmpi-$OMPI_VERSION && ./configure --prefix=$OMPI_DIR && make -j8 install
# Set env variables so we can compile our application
export PATH=$OMPI_DIR/bin:$PATH
export LD_LIBRARY_PATH=$OMPI_DIR/lib:$LD_LIBRARY_PATH
echo "Compiling the MPI application..."
cat<<EOF>/opt/mpitest.c
/*
* Usage:
* mpicc mpitest.c -o mpitest
* mpirun -np 2 -H `hostname` ./mpitest
*/
#include <stdio.h>
#include <mpi.h>
int main(int argc, char *argv[])
{
int rank, size, h_len;
char hostname[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
// get rank of this proces
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// get total process number
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(hostname, &h_len);
printf("Start! rank:%d size: %d at %s\n", rank, size,hostname);
//do something
printf("Done! rank:%d size: %d at %s\n", rank, size,hostname);
MPI_Finalize();
return 0;
}
EOF
cd /opt && mpicc -o mpitest mpitest.c
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment