return err
}
+ cachePath := filepath.Join(cwd, "punyci-cache-"+strconv.Itoa(job.id))
+ if job.Cache {
+ err := os.MkdirAll(cachePath, 0700)
+ if err != nil {
+ return err
+ }
+ }
+
// Start container but do not run the script yet. We need a way to a)
// sleep in case of an error so the user can analyze the failure and b)
// detect when the script terminates. The simplest solution is to run the
// script using exec while the container just sleeps forever.
- cmd := exec.Command("podman", "run", "--rm", "--detach",
+ args := []string{
+ "run", "--rm", "--detach",
"--pull", "newer",
"--log-driver", "none", // don't log to journal
- "--volume", repoPath+":/punyci-repo",
- "--volume", scriptPath+":/punyci-script:ro",
+ "--volume", repoPath + ":/punyci-repo",
+ "--volume", scriptPath + ":/punyci-script:ro",
+ }
+ if job.Cache {
+ args = append(args,
+ "--volume", cachePath+":/punyci-cache",
+ )
+ }
+ args = append(args,
"--entrypoint", "sh", // overwrite if set
"--",
job.Image,
"-c", "while :; do sleep 86400; done", // sleep forever
)
+ cmd := exec.Command("podman", args...)
out, err := cmd.Output()
if err != nil {
return err