Skip to content

Commit

Permalink
Move pipeline working dir from /app to /working.
Browse files Browse the repository at this point in the history
This should make it easier to ignore for when the pipeline
working directory is not the main code you want to run.

This happens e.g. when running tests inside your own just-built
container and similar. /app is too often already in use.
  • Loading branch information
Harald Nordgård-Hansen committed May 29, 2021
1 parent 3cec7e8 commit b02ebe0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/no/h_nh/docker_step/utils/DockerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ public static long runScript(String image, String script, String workingDir,
for (Map.Entry<String, String> entry : envVars.entrySet())
env.add(entry.getKey() + "=" + entry.getValue());
final ContainerConfig config = ContainerConfig.builder()
.image(image).cmd(script).workingDir("/app").user(user).env(env)
.image(image).cmd(script).workingDir("/working").user(user).env(env)
.attachStdin(true).attachStdout(true).attachStderr(true)
.hostConfig(HostConfig.builder().appendBinds(workingDir + ":/app").build())
.hostConfig(HostConfig.builder().appendBinds(workingDir + ":/working").build())
.build();
final ContainerCreation container = getDockerClient().createContainer(config);

Expand Down
6 changes: 2 additions & 4 deletions src/test/java/no/h_nh/docker_step/utils/DockerUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ public void startService() throws Exception {
ArgumentCaptor<ContainerConfig> containerConfig = ArgumentCaptor.forClass(ContainerConfig.class);
verify(dockerClient).createContainer(containerConfig.capture(), anyString());
assertEquals("Image wrong", "busybox:latest", containerConfig.getValue().image());
//assertEquals("Working dir incorrect", "/app", containerConfig.getValue().workingDir());
//assertEquals("Bind mount not correct", "/some-dir:/app", containerConfig.getValue().hostConfig().binds().get(0));
assertThat("Environment vars not correct", containerConfig.getValue().env(),
hasItems("ENV1=value1", "ENV2=value2"));
}
Expand Down Expand Up @@ -192,8 +190,8 @@ public void runScript() throws Exception {
ArgumentCaptor<ContainerConfig> containerConfig = ArgumentCaptor.forClass(ContainerConfig.class);
verify(dockerClient).createContainer(containerConfig.capture());
assertEquals("Image wrong", "busybox:latest", containerConfig.getValue().image());
assertEquals("Working dir incorrect", "/app", containerConfig.getValue().workingDir());
assertEquals("Bind mount not correct", "/some-dir:/app", containerConfig.getValue().hostConfig().binds().get(0));
assertEquals("Working dir incorrect", "/working", containerConfig.getValue().workingDir());
assertEquals("Bind mount not correct", "/some-dir:/working", containerConfig.getValue().hostConfig().binds().get(0));
assertThat("Environment vars not correct", containerConfig.getValue().env(),
hasItems("ENV1=value1", "ENV2=value2"));
}
Expand Down

0 comments on commit b02ebe0

Please sign in to comment.