Skip to content

Commit

Permalink
feat: Allow overriding temporary directory with $TMPDIR env var (#7)
Browse files Browse the repository at this point in the history
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":"<accountid>.dkr.ecr.<region>.amazonaws.com","ImageDigest":"<digest>","time":"2024-09-30T03:22:06Z","message":"SOCI index build error"}
  • Loading branch information
catkins authored Sep 30, 2024
1 parent d1fa23f commit 9c68e1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9c68e1d

Please sign in to comment.