18258: set the SINGULARITY_CACHEDIR to a path underneath our temporary
authorWard Vandewege <ward@curii.com>
Fri, 8 Oct 2021 14:24:28 +0000 (10:24 -0400)
committerWard Vandewege <ward@curii.com>
Fri, 8 Oct 2021 14:24:28 +0000 (10:24 -0400)
       space, and clean up after we're done building.

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/crunchrun/singularity.go

index 70ad653b7d5a8934a49a33532789c4ee77da3e85..9828d8734e021825e2f64a4846f323ae147b9258 100644 (file)
@@ -160,7 +160,12 @@ func (e *singularityExecutor) LoadImage(dockerImageID string, imageTarballPath s
                        return err
                }
 
+               os.Mkdir(e.tmpdir+"/cache", 0700)
+               defer os.RemoveAll(e.tmpdir + "/cache")
+
                build := exec.Command("singularity", "build", imageFilename, "docker-archive://"+e.tmpdir+"/image.tar")
+               build.Env = os.Environ()
+               build.Env = append(build.Env, "SINGULARITY_CACHEDIR="+e.tmpdir+"/cache")
                e.logf("%v", build.Args)
                out, err := build.CombinedOutput()
                // INFO:    Starting build...