Skip to content

Commit

Permalink
Unless already in the environment, set HOME to /working.
Browse files Browse the repository at this point in the history
This should prevent a lot of "you cannot write in that place" errors,
and also make some default caching strategies just work better.
  • Loading branch information
Harald Nordgård-Hansen committed May 31, 2021
1 parent 0c61c44 commit 041392a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/no/h_nh/docker_step/utils/DockerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public static long runScript(String image, String script, String workingDir,
final List<String> env = new ArrayList<>(envVars.size());
for (Map.Entry<String, String> entry : envVars.entrySet())
env.add(entry.getKey() + "=" + entry.getValue());
// Unless already set, make HOME point to /working to avoid a number of problems.
if (!envVars.containsKey("HOME"))
env.add("HOME=/working");
final ContainerConfig config = ContainerConfig.builder()
.image(image).cmd(script).workingDir("/working").user(user).env(env)
.attachStdin(true).attachStdout(true).attachStderr(true)
Expand Down

0 comments on commit 041392a

Please sign in to comment.