Support ONBUILD instruction in Dockerfiles by orzeh · Pull Request #393 · docker-java/docker-java · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ public void testDockerBuilderFromTar() throws Exception {
assertThat(response, containsString("Successfully executed testrun.sh"));
}

@Test
public void testDockerBuildWithOnBuild() throws Exception {
File baseDir = new File(Thread.currentThread().getContextClassLoader().getResource("testAddOnBuild/onbuild").getFile());
dockerClient.buildImageCmd(baseDir)
.withNoCache(true)
.withTag("docker-java-onbuild")
.exec(new BuildImageResultCallback())
.awaitImageId();
baseDir = new File(Thread.currentThread().getContextClassLoader().getResource("testAddOnBuild/test").getFile());
String response = dockerfileBuild(baseDir);
assertThat(response, containsString("Successfully executed testrun.sh"));
}

@Test
public void testDockerBuilderAddUrl() throws Exception {
File baseDir = new File(Thread.currentThread().getContextClassLoader().getResource("testAddUrl").getFile());
Expand Down
8 changes: 8 additions & 0 deletions src/test/resources/testAddOnBuild/onbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:latest

# Copy testrun.sh files into the container

ONBUILD ADD ./testrun.sh /tmp/
ONBUILD RUN cp /tmp/testrun.sh /usr/local/bin/ && chmod +x /usr/local/bin/testrun.sh

CMD ["testrun.sh"]
1 change: 1 addition & 0 deletions src/test/resources/testAddOnBuild/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM docker-java-onbuild
3 changes: 3 additions & 0 deletions src/test/resources/testAddOnBuild/test/testrun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Successfully executed testrun.sh"
2 changes: 1 addition & 1 deletion src/test/resources/testDockerignore/.dockerignore