Skip to content

Commit

Permalink
Merge pull request #34494 from gsmet/restore-entrypoint
Browse files Browse the repository at this point in the history
Restore ENTRYPOINT in Dockerfile templates
  • Loading branch information
gsmet authored Jul 5, 2023
2 parents 86d5083 + 03ce8e9 commit e870b5d
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ language:
package: package
package-uber-jar: package -Dquarkus.package.type=uber-jar
package-legacy-jar: package -Dquarkus.package.type=legacy-jar
package-native: package -Pnative
package-native-container: package -Pnative -Dquarkus.native.container-build=true
package-native: package -Dnative
package-native-container: package -Dnative -Dquarkus.native.container-build=true
build-ci: verify -B
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ ENV AB_JOLOKIA_OFF=""
{/if}
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ COPY --chown=1001:root {buildtool.build-dir}/*-runner /work/application
EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ COPY --chown=1001:root {buildtool.build-dir}/*-runner /work/application
EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static io.quarkus.devtools.testing.FakeExtensionCatalog.FAKE_QUARKUS_CODESTART_CATALOG;
import static io.quarkus.devtools.testing.SnapshotTesting.assertThatMatchSnapshot;
import static io.quarkus.devtools.testing.SnapshotTesting.checkContains;
import static io.quarkus.devtools.testing.SnapshotTesting.checkNotContains;
import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Path;
Expand Down Expand Up @@ -210,6 +209,25 @@ void generateMavenDefaultJava(TestInfo testInfo) throws Throwable {
assertThatMatchSnapshot(testInfo, projectDir, "src/test/java/org/acme/GreetingResourceIT.java");
}

@Test
void generateGradleDefaultJava(TestInfo testInfo) throws Throwable {
final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
.buildTool(BuildTool.GRADLE)
.addData(getGenerationTestInputData())
.build();
final Path projectDir = testDirPath.resolve("gradle-default-java");
getCatalog().createProject(input).generate(projectDir);

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

assertThatMatchSnapshot(testInfo, projectDir, "src/main/java/org/acme/GreetingResource.java");
assertThatMatchSnapshot(testInfo, projectDir, "src/test/java/org/acme/GreetingResourceTest.java");
assertThatMatchSnapshot(testInfo, projectDir, "src/native-test/java/org/acme/GreetingResourceIT.java");
}

@Test
void generateMavenResteasyJava(TestInfo testInfo) throws Throwable {
final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder()
Expand Down Expand Up @@ -299,47 +317,49 @@ private void checkDockerfilesWithMaven(Path projectDir) {
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))//TODO: make a test for java17
.satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\""))
.satisfies(checkNotContains("ENTRYPOINT"));
.satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.legacy-jar")).exists()
.satisfies(checkContains("./mvnw package -Dquarkus.package.type=legacy-jar"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.legacy-jar"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))
.satisfies(checkContains("EXPOSE 8080"))
.satisfies(checkContains("USER 185"))
.satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\""))
.satisfies(checkNotContains("ENTRYPOINT"));
.satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native-micro")).exists()
.satisfies(checkContains("./mvnw package -Pnative"))
.satisfies(checkContains("./mvnw package -Dnative"))
.satisfies(checkContains("quay.io/quarkus/quarkus-micro-image:2.0"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
.satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists()
.satisfies(checkContains("./mvnw package -Pnative"))
.satisfies(checkContains("./mvnw package -Dnative"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
.satisfies(checkContains("ENTRYPOINT [\"./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("./gradlew build"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.8"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
.satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))//TODO: make a test for java17
.satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\""))
.satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.legacy-jar")).exists()
.satisfies(checkContains("./gradlew build -Dquarkus.package.type=legacy-jar"))
.satisfies(checkContains("docker build -f src/main/docker/Dockerfile.legacy-jar"))
.satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.8"))
.satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless"))
.satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]"));
.satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))
.satisfies(checkContains("EXPOSE 8080"))
.satisfies(checkContains("USER 185"))
.satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\""))
.satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]"));
assertThat(projectDir.resolve("src/main/docker/Dockerfile.native-micro")).exists()
.satisfies(checkContains("./gradlew build -Dquarkus.package.type=native"))
.satisfies(checkContains("quay.io/quarkus/quarkus-micro-image:2.0"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
.satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
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"))
.satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
.satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]"));
}

private void checkConfigProperties(Path projectDir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ The application, packaged as an _über-jar_, is now runnable using `java -jar ta

You can create a native executable using:
```shell script
mvn package -Pnative
mvn package -Dnative
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
mvn package -Pnative -Dquarkus.native.container-build=true
mvn package -Dnative -Dquarkus.native.container-build=true
```

You can then execute your native executable with: `./target/test-codestart-1.0.0-codestart-runner`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello from RESTEasy Reactive";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.acme;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class GreetingResourceIT extends GreetingResourceTest {

// Execute the same tests but in native mode.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.acme;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
public class GreetingResourceTest {

@Test
public void testHelloEndpoint() {
given()
.when().get("/hello")
.then()
.statusCode(200)
.body(is("Hello from RESTEasy Reactive"));
}

}
4 changes: 2 additions & 2 deletions integration-tests/elasticsearch-rest-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The application is now runnable using `java -jar target/quarkus-integration-test

## Creating a native executable

You can create a native executable using: `./mvnw package -Pnative`.
You can create a native executable using: `./mvnw package -Dnative`.

Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Dnative -Dquarkus.native.container-build=true`.

You can then execute your native executable with: `./target/quarkus-integration-test-elasticsearch-rest-client-1.0-SNAPSHOT-runner`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The application is now runnable using `java -jar target/quarkus-integration-test

## Creating a native executable

You can create a native executable using: `./mvnw package -Pnative`.
You can create a native executable using: `./mvnw package -Dnative`.

Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Dnative -Dquarkus.native.container-build=true`.

You can then execute your native executable with: `./target/quarkus-integration-test-elasticsearch-rest-high-level-client-1.0-SNAPSHOT-runner`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void testJavaLibraryPathAtRuntime() throws Exception {
final File testDir = initProject("projects/native-image-app", "projects/native-image-app-output");
final RunningInvoker running = new RunningInvoker(testDir, false);

// trigger mvn package -Pnative -Dquarkus.ssl.native=true
final String[] mvnArgs = new String[] { "package", "-DskipTests", "-Pnative", "-Dquarkus.ssl.native=true" };
// trigger mvn package -Dnative -Dquarkus.ssl.native=true
final String[] mvnArgs = new String[] { "package", "-DskipTests", "-Dnative", "-Dquarkus.ssl.native=true" };
final MavenProcessInvocationResult result = running.execute(Arrays.asList(mvnArgs), Collections.emptyMap());
await().atMost(10, TimeUnit.MINUTES).until(() -> result.getProcess() != null && !result.getProcess().isAlive());
final String processLog = running.log();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Before building the container image run:
#
# ./mvnw package -Pnative
# ./mvnw package -Dnative
#
# Then, build the image with:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Before building the container image run:
#
# ./mvnw package -Pnative
# ./mvnw package -Dnative
#
# Then, build the image with:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
Expand Down

0 comments on commit e870b5d

Please sign in to comment.