Commit f33865c9 authored by Mulas, Giacomo's avatar Mulas, Giacomo
Browse files

created the .def file that builds a minimal singularity image in which all the...

created the .def file that builds a minimal singularity image in which all the mp-tmcode codes can be run, including all the needed runtime files
parent 67eb1ee9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ build/cluster/*
build/sphere/*
build/trapping/*
doc/build/*
containers/singularity/*.sif
+19 −0
Original line number Diff line number Diff line
# Singularity support for the NP-TMcode project

This `np-tmcode-run.def` file allows to create a np-tmcode-run image, that contains only the pre-built executables, python test scripts, compiled documentation, and the minimal runtime to run them

In order for the singularity build to create the image, singularity build must be invoked from this directory as:

   > singularity build \<image name\> np-tmcode-run.def

where `<image name>` is the name one wants to give to the image, e.g. `np-tmcode-run.sif`. Depending on the singularity installation, the additional `--fakeroot` option may be needed (see singularity documentation).

The image thus built can be run either as

   > singularity run \<image name\> \<np-tmcode command\>

or directly as

   > \<full path to image name\> \<np-tmcode command\>

where `<full path to image name>` is the name of the sif image, including full or relative path to it, and `<np-tmcode command>` is one of the executables built in np-tmcode project, or the `pycompare.py` script used to compare results between the Fortran and C++ versions of the code. These executables, as well as the minimum runtime for them to execute correctly, are embedded in the image, and "see" the current directory the image is run in (which technically is automatically bind-mounted by singularity in the running image instance).
 No newline at end of file
+62 −0
Original line number Diff line number Diff line
Bootstrap: docker
From: debian:bookworm-slim
Stage: np-tmcode-run-dev

%files
	../../src /usr/local/np-tmcode/src
	../../doc /usr/local/np-tmcode/doc
	../../build /usr/local/np-tmcode/build
	../../test_data /usr/local/np-tmcode/test_data

%post
	apt update
	apt -y upgrade
	apt -y install g++ gfortran make gcc-offload-nvptx libhdf5-dev
	apt -y install python3 python-is-python3 python3-regex
	apt -y install doxygen
	apt -y install texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-font-utils
	rm -rf /var/lib/apt/lists/*
	cd /usr/local/np-tmcode/src
	make wipe
	make -j
	make docs -j && make -C ../doc/build/latex -j


Bootstrap: docker
From: debian:bookworm-slim
Stage: np-tmcode-run-minimal

%files from np-tmcode-run-dev
       /usr/local/np-tmcode /usr/local/np-tmcode

%post
	apt update
	apt -y upgrade
	apt -y install libgfortran5 libgcc-s1 libhdf5-103-1 libstdc++6 libssl3 libcurl4 libsz2 zlib1g libnghttp2-14 libidn2-0 librtmp1 libssh2-1 libpsl5 libgssapi-krb5-2 libldap-2.5-0 libzstd1 libbrotli1 libaec0 libunistring2 libgmp10 libkrb5-3 libk5crypto3 libcom-err2 libkrb5support0 libsasl2-2 libp11-kit0 libtasn1-6 libkeyutils1 libffi8 python3 python-is-python3 python3-regex
	rm -rf /var/lib/apt/lists/*
	cd /usr/local/np-tmcode
	find build -name "*.o" -exec rm -v \{\} \;
	find build -name "*.gcno" -exec rm -v \{\} \;
	cd src
	rm -rvf cluster libnptm trapping include sphere Makefile make.inc README.md
	cd ..
	rm -rvf containers
	cd doc
	rm -rvf src/cluster /src/include /src/libntpm /src/sphere /src/trapping /src/Makefile /src/make.inc
	cd build/latex
	rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf
	cp -a /usr/bin/ld.so /usr/bin/sh /usr/bin/dash /usr/bin/mkdir /usr/bin/rm /usr/bin/cp /usr/bin/python* /usr/local/bin/
	rm -rvf /bin/* /usr/bin/* /sbin /usr/sbin /usr/games /usr/local/games
	/usr/local/bin/mkdir -p /bin
	/usr/local/bin/cp -av /usr/local/bin/* /bin/
	rm -rvf /usr/local/bin/* /bin/cp /bin/rm /bin/mkdir


Bootstrap: scratch
Stage: np-tmcode-run

%files from np-tmcode-run-minimal
       / /

%runscript
	PATH=/bin:/usr/local/np-tmcode/src/scripts:/usr/local/np-tmcode/build/trapping:/usr/local/np-tmcode/build/cluster:/usr/local/np-tmcode/build/sphere $*