10
10
from DIRAC import S_ERROR , gConfig , gLogger
11
11
from DIRAC .Core .Base .Script import Script
12
12
from DIRAC .Core .Security .Locations import getCAsLocation , getProxyLocation , getVOMSLocation
13
+ from DIRAC .Core .Utilities .Os import safe_listdir
13
14
from DIRAC .Core .Utilities .Subprocess import systemCall
14
15
15
16
@@ -73,7 +74,7 @@ def main():
73
74
cmd .extend (["--contain" ]) # use minimal /dev and empty other directories (e.g. /tmp and $HOME)
74
75
cmd .extend (["--ipc" ]) # run container in a new IPC namespace
75
76
cmd .extend (["--pid" ]) # run container in a new PID namespace
76
- cmd .extend (["--bind" , f"{ os .getcwd ()} :/mnt " ]) # bind current directory for dirac_container.sh
77
+ cmd .extend (["--bind" , f"{ os .getcwd ()} :/" ]) # bind current directory for dirac_container.sh
77
78
if proxy_location :
78
79
cmd .extend (["--bind" , f"{ proxy_location } :/etc/proxy" ]) # bind proxy file
79
80
cmd .extend (["--bind" , f"{ getCAsLocation ()} :/etc/grid-security/certificates" ]) # X509_CERT_DIR
@@ -83,12 +84,18 @@ def main():
83
84
cmd .extend (["--bind" , f"{ vomses_location } :/etc/grid-security/vomses" ]) # X509_VOMSES
84
85
cmd .extend (["--bind" , "{0}:{0}:ro" .format (etc_dir )]) # etc dir for dirac.cfg
85
86
cmd .extend (["--bind" , "{0}:{0}:ro" .format (os .path .join (os .path .realpath (sys .base_prefix )))]) # code dir
86
- cmd .extend (["--cwd" , "/mnt" ]) # set working directory to /mnt
87
+ # here bind optional paths
88
+ for bind_path in gConfig .getValue ("/Resources/Computing/Singularity/BindPaths" , []):
89
+ if safe_listdir (bind_path ):
90
+ cmd .extend (["--bind" , f"{ bind_path } :{ bind_path } " ])
91
+ else :
92
+ gLogger .warning (f"Bind path { bind_path } does not exist, skipping" )
93
+ cmd .extend (["--cwd" , "/" ]) # set working directory
87
94
88
95
rootImage = user_image or gConfig .getValue ("/Resources/Computing/Singularity/ContainerRoot" ) or CONTAINER_DEFROOT
89
96
90
97
if os .path .isdir (rootImage ) or os .path .isfile (rootImage ):
91
- cmd .extend ([rootImage , "/mnt /dirac_container.sh" ])
98
+ cmd .extend ([rootImage , ". /dirac_container.sh" ])
92
99
else :
93
100
# if we are here is because there's no image, or it is not accessible (e.g. not on CVMFS)
94
101
gLogger .error ("Apptainer image to exec not found: " , rootImage )
0 commit comments