-
Notifications
You must be signed in to change notification settings - Fork 1
/
Singularity.higgsPheno
126 lines (111 loc) · 3.75 KB
/
Singularity.higgsPheno
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
####
# to build me
# sudo singularity build higgsPheno.sif higgsPheno.def
####
# to run me do
# singularity run --containall --bind /my/out/dir/ higgsPheno.sif
# the "--containall" flag prevents interactions with your system
# the "--bind /my/out/dir/" mounts a directory in your system
# this allows scripts in that directory to be accessed from the image
# and results from the image to persist in the directory
# It also allows the run script to call .bashrc
BootStrap: docker
From: ubuntu:18.04
# commands on the host system
%setup
# make print colour #
GREEN='\033[0;32m'
NOCOLOUR='\033[0m'
echo "${GREEN}~~~ Getting modified packages from github ~~~ ${NOCOLOUR}"
export PACKAGES_TMP=/tmp/packages
rm -fr $PACKAGES_TMP
mkdir -p $PACKAGES_TMP
git clone https://github.com/HenryDayHall/higgsPhenoPackages.git $PACKAGES_TMP
cp -R ${PACKAGES_TMP} ${SINGULARITY_ROOTFS}
# get files from the host (but we dont need any)
%files
/home/henry/Programs/singularity_conts/higgsPheno/host_test a
/home/henry/Programs/singularity_conts/higgsPheno/host_test_file b
# what is done when the container is built
%post
# make print colour #
GREEN='\033[0;32m'
NOCOLOUR='\033[0m'
# start
echo "${GREEN}~~~ install apt packages ~~~ ${NOCOLOUR}"
apt -y update
# for scripts
apt -y install python2.7
# for fetching from repos if needed
apt -y install git
# for getting anything else from the net
apt -y install wget
# text editors
apt -y install vim-tiny
apt -y install nano
# for making downloaded packages
apt -y install make
# for compiling 2HDMC
apt -y install libgsl-dev
apt -y install g++
echo "${GREEN}~~~ Set up a .bashrc ~~~ ${NOCOLOUR}"
BASHRC=/home/.bashrc
touch $BASHRC
echo "alias vim=vim.tiny\n" >> $BASHRC
echo "alias python=python2.7\n" >> $BASHRC
# will be called in run
## Not working???
## the /home/ directory appears empty
# echo "${GREEN}~~~ Move packages to home dir ~~~ ${NOCOLOUR}"
MY_HOME=$(ls -l /home/)
echo in post home is $MY_HOME
echo $USER
# PACKAGES=$MY_HOME/packages/
# mv /packages $PACKAGES
#echo "${GREEN}~~~ Give the user permission and control ~~~ ${NOCOLOUR}"
PACKAGES=/packages
#chown -R $USER $PACKAGES
#chmod -R 766 $PACKAGES
echo "${GREEN}~~~ Making the packages ~~~ ${NOCOLOUR}"
echo "${GREEN}~~~ 2HDMC ~~~ ${NOCOLOUR}"
cd $PACKAGES/2HDMC
# for some reason the lib dir is not automaticaly constructed
mkdir lib
make
# enviroment variabels instide the container
# sourced at run time not build time
%environment
export PACKAGES=/packages/
export BASHRC=/home/.bashrc
# this is executed when the contain is launched with
# singularity run higgsPheno.sif
%runscript
# make print colour #
GREEN='\033[0;32m'
NOCOLOUR='\033[0m'
cp -r /packages/* ~/
echo "${GREEN}Test me with"
echo "\$ cd 2HDMC"
echo "\$ make test2HDMC"
echo "\$ ./test2HDMC ${NOCOLOUR}"
/bin/bash --rcfile $BASHRC
# this would be executed just after build
%test
echo I havent written any tests
MY_HOME=$(ls -l /home/)
echo in test home is $MY_HOME
echo $USER
# metadata
%labels
Author HenryDayHall
Version v1.0
%help
to build me
> sudo singularity build higgsPheno.sif higgsPheno.def
to run me do
> singularity run --containall --bind /my/out/dir/ higgsPheno.sif
the "--containall" flag prevents interactions with your system
the "--bind /my/out/dir/" mounts a directory in your system
this allows scripts in that directory to be accessed from the image
and results from the image to persist in the directory
It also allows the run script to call .bashrc