Skip to content

Commit

Permalink
Use buildtool build command in Dockerfile documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
glefloch committed Oct 20, 2020
1 parent 60dd703 commit a0fcba8
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ language:
cmd:
dev: quarkusDev
package: build
package-uberjar: build -Dquarkus.package.type=uber-jar
package-uber-jar: build -Dquarkus.package.type=uber-jar
package-fast-jar: build -Dquarkus.package.type=fast-jar
package-native: build -Dquarkus.package.type=native
package-native-container: build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ language:
cmd:
dev: quarkusDev
package: build
package-uberjar: build --Dquarkus.package.type=uber-jar
package-uber-jar: build -Dquarkus.package.type=uber-jar
package-fast-jar: build -Dquarkus.package.type=fast-jar
package-native: build -Dquarkus.package.type=native
package-native-container: build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ language:
cmd:
dev: compile quarkus:dev
package: package
package-uberjar: package -Dquarkus.package.type=uber-jar
package-uber-jar: package -Dquarkus.package.type=uber-jar
package-fast-jar: package -Dquarkus.package.type=fast-jar
package-native: package -Pnative
package-native-container: package -Pnative -Dquarkus.native.container-build=true
build-ci: verify -B
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Be aware that it’s not an _über-jar_ as the dependencies are copied into the

If you want to build an _über-jar_, execute the following command:
```shell script
{buildtool.cli} {buildtool.cmd.package-uberjar}
{buildtool.cli} {buildtool.cmd.package-uber-jar}
```

The application is now runnable using `java -jar {buildtool.build-dir}/{project.artifact-id}-{project.version}-runner.jar`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Before building the container image run:
#
# {#insert quarkusbuild} mvn package {/}
# {#insert quarkusbuild /}
#
# Then, build the image with:
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#include Dockerfile-layout type='fast-jar'}
{#quarkusbuild}mvn package -Dquarkus.package.type=fast-jar{/quarkusbuild}
{#quarkusbuild}{buildtool.cli} {buildtool.cmd.package-fast-jar}{/quarkusbuild}
{#image}{dockerfile.fast-jar.from} {/image}
{#args}
ARG JAVA_PACKAGE={dockerfile.fast-jar.java-package}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{#include Dockerfile-layout type='jvm'}
{#image}{dockerfile.jvm.from} {/}
{#quarkusbuild}{buildtool.cli} {buildtool.cmd.package}{/quarkusbuild}
{#image}{dockerfile.jvm.from} {/image}
{#args}
ARG JAVA_PACKAGE={dockerfile.jvm.java-package}
ARG RUN_JAVA_VERSION={dockerfile.jvm.run-java-version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Before building the container image run:
#
# mvn package -Pnative -Dquarkus.native.container-build=true
# {buildtool.cli} {buildtool.cmd.package-native}
#
# Then, build the image with:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void generateCodestartProjectCommandMode() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/commandmode/HelloCommando.java")).exists();
Expand All @@ -110,7 +110,7 @@ void generateCodestartProjectCommandModeCustom() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/com/test/andy/AndyCommando.java")).exists()
Expand All @@ -132,7 +132,7 @@ void generateCodestartProjectRESTEasyJavaCustom() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/com/andy/BonjourResource.java")).exists()
Expand Down Expand Up @@ -189,7 +189,7 @@ void generateCodestartProjectRESTEasyKotlinCustom() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/kotlin/com/andy/BonjourResource.kt")).exists()
Expand Down Expand Up @@ -222,7 +222,7 @@ void generateCodestartProjectRESTEasyScalaCustom() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/scala/com/andy/BonjourResource.scala")).exists()
Expand Down Expand Up @@ -250,7 +250,7 @@ void generateCodestartProjectMavenDefaultJava() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/resteasy/ExampleResource.java")).exists();
Expand All @@ -269,7 +269,7 @@ void generateCodestartProjectMavenResteasyJava() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/resteasy/ExampleResource.java")).exists();
Expand All @@ -288,7 +288,7 @@ void generateCodestartProjectMavenConfigYamlJava() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigYaml(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/config/GreetingResource.java")).exists();
Expand All @@ -306,7 +306,7 @@ void generateCodestartProjectMavenResteasyKotlin() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/kotlin/org/acme/resteasy/ExampleResource.kt")).exists();
Expand All @@ -326,7 +326,7 @@ void generateCodestartProjectMavenResteasyScala() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/scala/org/acme/resteasy/ExampleResource.scala")).exists();
Expand All @@ -347,7 +347,7 @@ void generateCodestartProjectGradleResteasyJava() throws IOException {

checkGradle(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/resteasy/ExampleResource.java")).exists();
Expand All @@ -369,7 +369,7 @@ void generateCodestartProjectGradleResteasyKotlin() throws IOException {

checkGradle(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/kotlin/org/acme/resteasy/ExampleResource.kt")).exists();
Expand All @@ -390,7 +390,7 @@ void generateCodestartProjectGradleResteasyScala() throws IOException {

checkGradle(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/scala/org/acme/resteasy/ExampleResource.scala")).exists();
Expand All @@ -410,7 +410,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyJava() throws IOExceptio

checkGradleWithKotlinDsl(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE_KOTLIN_DSL);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/resteasy/ExampleResource.java")).exists();
Expand All @@ -429,7 +429,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyKotlin() throws IOExcept

checkGradleWithKotlinDsl(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE_KOTLIN_DSL);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/kotlin/org/acme/resteasy/ExampleResource.kt")).exists();
Expand All @@ -448,7 +448,7 @@ void generateCodestartProjectGradleWithKotlinDslResteasyScala() throws IOExcepti

checkGradleWithKotlinDsl(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.GRADLE_KOTLIN_DSL);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/scala/org/acme/resteasy/ExampleResource.scala")).exists();
Expand All @@ -466,7 +466,7 @@ void generateCodestartProjectQute() throws IOException {

checkMaven(projectDir);
checkReadme(projectDir);
checkDockerfiles(projectDir);
checkDockerfiles(projectDir, BuildTool.MAVEN);
checkConfigProperties(projectDir);

assertThat(projectDir.resolve("src/main/java/org/acme/qute/Item.java")).exists();
Expand Down Expand Up @@ -516,21 +516,56 @@ private void checkNoExample(Path projectDir) {
assertThat(projectDir.resolve("src/main/scala")).doesNotExist();
}

private void checkDockerfiles(Path projectDir) {
private void checkDockerfiles(Path projectDir, BuildTool buildTool) {
switch (buildTool) {
case MAVEN:
checkDockerfilesWithMaven(projectDir);
break;
case GRADLE_KOTLIN_DSL:
case GRADLE:
checkDockerfilesWithGradle(projectDir);
break;
default:
throw new IllegalArgumentException("Unhandled buildtool");
}
}

private void checkDockerfilesWithMaven(Path projectDir) {
assertThat(projectDir.resolve(".dockerignore")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.jvm")).exists()
.satisfies(checkContains("./mvnw package"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.fast-jar")).exists()
.satisfies(checkContains("./mvnw package -Dquarkus.package.type=fast-jar"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.fast-jar"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists()
.satisfies(checkContains("./mvnw package -Pnative"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
}

private void checkDockerfilesWithGradle(Path projectDir) {
assertThat(projectDir.resolve(".dockerignore")).exists();
assertThat(projectDir.resolve("src/main/docker/Dockerfile.jvm")).exists()
.satisfies(checkContains("mvn package"))
.satisfies(checkContains("./gradlew build"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.fast-jar")).exists()
.satisfies(checkContains("mvn package -Dquarkus.package.type=fast-jar"))
.satisfies(checkContains("./gradlew build -Dquarkus.package.type=fast-jar"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.fast-jar"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists()
.satisfies(checkContains("./gradlew build -Dquarkus.package.type=native"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.1"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
}
Expand Down

0 comments on commit a0fcba8

Please sign in to comment.