From 9c68e1dd42f484a0999b0d00795ef07ae91b23c5 Mon Sep 17 00:00:00 2001 From: Chris Atkins Date: Tue, 1 Oct 2024 00:00:34 +1000 Subject: [PATCH] feat: Allow overriding temporary directory with $TMPDIR env var (#7) Sometimes /tmp doesn't have enough space. Allow overriding that path with $TMPDIR. Example error: {"level":"error","error":"errors encountered while building soci layers; write /tmp/tmp.3943925700: no space left on device; write /tmp/tmp.1788043098: no space left on device","RegistryURL":".dkr.ecr..amazonaws.com","ImageDigest":"","time":"2024-09-30T03:22:06Z","message":"SOCI index build error"} --- handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler.go b/handler.go index a630443..4f61f5d 100644 --- a/handler.go +++ b/handler.go @@ -99,11 +99,11 @@ func indexAndPush(ctx context.Context, repo string, digest string, registryUrl s return BuildAndPushSuccessMessage, nil } -// Create a temp directory in /tmp +// Create a temp directory in /tmp or $TMPDIR // The directory is prefixed by the Lambda's request id func createTempDir(ctx context.Context) (string, error) { log.Info(ctx, "Creating a directory to store images and SOCI artifacts") - tempDir, err := os.MkdirTemp("/tmp", "soci") // The temp dir name is prefixed by the request id + tempDir, err := os.MkdirTemp("", "soci") // The temp dir name is prefixed by the request id return tempDir, err }