diff --git a/README.md b/README.md index ac66f99da..5ebdc2fce 100644 --- a/README.md +++ b/README.md @@ -454,9 +454,13 @@ Checks that the application can read configuration from a ConfigMap and a Secret The ConfigMap/Secret is exposed by mounting it into the container file system or the Kubernetes API server. Also ensures proper integration of SmallRye Config [Secret Keys](https://smallrye.io/smallrye-config/Main/config/secret-keys/) with Quarkus. -### `docker-build` +### `build/docker-build` Checks that an application can generate a Docker image based on some configuration parameters. +### `build/podman` +Checks that an application can generate a Docker image using podman extension. + + ### `lifecycle-application` Verifies lifecycle application features like `@QuarkusMain` and `@CommandLineArguments`. Also ensures maven profile activation with properties and additional repository definition propagation into Quarkus maven plugin. diff --git a/docker-build/pom.xml b/build/docker/pom.xml similarity index 98% rename from docker-build/pom.xml rename to build/docker/pom.xml index 5023cdb6b..1d9970fe5 100644 --- a/docker-build/pom.xml +++ b/build/docker/pom.xml @@ -5,7 +5,7 @@ io.quarkus.ts.qe parent 1.0.0-SNAPSHOT - .. + ../.. docker-build jar diff --git a/docker-build/src/main/docker/Dockerfile.jvm b/build/docker/src/main/docker/Dockerfile.jvm similarity index 100% rename from docker-build/src/main/docker/Dockerfile.jvm rename to build/docker/src/main/docker/Dockerfile.jvm diff --git a/docker-build/src/main/docker/Dockerfile.native b/build/docker/src/main/docker/Dockerfile.native similarity index 100% rename from docker-build/src/main/docker/Dockerfile.native rename to build/docker/src/main/docker/Dockerfile.native diff --git a/docker-build/src/main/java/io/quarkus/ts/docker/HelloResource.java b/build/docker/src/main/java/io/quarkus/ts/docker/HelloResource.java similarity index 100% rename from docker-build/src/main/java/io/quarkus/ts/docker/HelloResource.java rename to build/docker/src/main/java/io/quarkus/ts/docker/HelloResource.java diff --git a/docker-build/src/main/resources/application.properties b/build/docker/src/main/resources/application.properties similarity index 100% rename from docker-build/src/main/resources/application.properties rename to build/docker/src/main/resources/application.properties diff --git a/docker-build/src/test/java/io/quarkus/ts/docker/DockerBuildIT.java b/build/docker/src/test/java/io/quarkus/ts/docker/DockerBuildIT.java similarity index 100% rename from docker-build/src/test/java/io/quarkus/ts/docker/DockerBuildIT.java rename to build/docker/src/test/java/io/quarkus/ts/docker/DockerBuildIT.java diff --git a/docker-build/src/test/java/io/quarkus/ts/docker/NativeConfigurationIT.java b/build/docker/src/test/java/io/quarkus/ts/docker/NativeConfigurationIT.java similarity index 100% rename from docker-build/src/test/java/io/quarkus/ts/docker/NativeConfigurationIT.java rename to build/docker/src/test/java/io/quarkus/ts/docker/NativeConfigurationIT.java diff --git a/build/podman/pom.xml b/build/podman/pom.xml new file mode 100644 index 000000000..36378ceff --- /dev/null +++ b/build/podman/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + io.quarkus.ts.qe + parent + 1.0.0-SNAPSHOT + ../.. + + podman-build + jar + Quarkus QE TS: Podman-build + + true + + + + io.quarkus + quarkus-rest-jackson + + + io.quarkus + quarkus-container-image-podman + + + + + + skip-tests-on-windows + + + windows + + + !linux-containers-available + + + + false + + + + + maven-surefire-plugin + + true + + + + maven-failsafe-plugin + + true + + + + + + + diff --git a/build/podman/src/main/docker/Dockerfile.jvm b/build/podman/src/main/docker/Dockerfile.jvm new file mode 100644 index 000000000..29545f743 --- /dev/null +++ b/build/podman/src/main/docker/Dockerfile.jvm @@ -0,0 +1,40 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/getting-started-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/getting-started-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/getting-started-jvm +# +### +FROM registry.access.redhat.com/ubi8/openjdk-17:latest + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV AB_JOLOKIA_OFF="" +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" + diff --git a/build/podman/src/main/docker/Dockerfile.native b/build/podman/src/main/docker/Dockerfile.native new file mode 100644 index 000000000..bc4399f20 --- /dev/null +++ b/build/podman/src/main/docker/Dockerfile.native @@ -0,0 +1,25 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/getting-started . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/getting-started +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application +EXPOSE 8080 +USER 1001 +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/build/podman/src/main/java/io/quarkus/ts/docker/HelloResource.java b/build/podman/src/main/java/io/quarkus/ts/docker/HelloResource.java new file mode 100644 index 000000000..45266e6dc --- /dev/null +++ b/build/podman/src/main/java/io/quarkus/ts/docker/HelloResource.java @@ -0,0 +1,16 @@ +package io.quarkus.ts.docker; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +@Path("/hello") +public class HelloResource { + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response get() { + return Response.ok("hello World").build(); + } +} diff --git a/build/podman/src/main/resources/application.properties b/build/podman/src/main/resources/application.properties new file mode 100644 index 000000000..4f44d5955 --- /dev/null +++ b/build/podman/src/main/resources/application.properties @@ -0,0 +1,4 @@ +quarkus.container-image.group=qe +# DON'T remove the spaces that are at the end of quarkus app name +quarkus.application.name=hello-world-podman-app +quarkus.container-image.tag=1.0.0 diff --git a/build/podman/src/test/java/io/quarkus/ts/docker/PodmanBuildIT.java b/build/podman/src/test/java/io/quarkus/ts/docker/PodmanBuildIT.java new file mode 100644 index 000000000..a5f7ebe5c --- /dev/null +++ b/build/podman/src/test/java/io/quarkus/ts/docker/PodmanBuildIT.java @@ -0,0 +1,40 @@ +package io.quarkus.ts.docker; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Objects; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +import com.github.dockerjava.api.model.Image; + +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.utils.DockerUtils; + +@QuarkusScenario +@EnabledIfEnvironmentVariable(named = "DOCKER_HOST", matches = ".*podman.*") +/** + * We run the tests only when podman is enabled and does not pretend to be Docker + * since otherwise we won't be able to distinguish between the extension being broken + * and a situation, when podman is not installed. + * + * Unfortunately, that means, that the test is disabled on Windows and Mac + */ +public class PodmanBuildIT { + // Local container build, no need in tracking image in properties + private static final String IMAGE_NAME = "hello-world-podman-app"; + private static final String IMAGE_VERSION = "1.0.0"; + + @AfterAll + public static void tearDown() { + DockerUtils.removeImage(IMAGE_NAME, IMAGE_VERSION); + } + + @Test + public void verifyImageNameWithSpaces() { + Image image = DockerUtils.getImage(IMAGE_NAME, IMAGE_VERSION); + assertTrue(Objects.nonNull(image.getId()) && !image.getId().isEmpty(), "The image was not created"); + } +} diff --git a/pom.xml b/pom.xml index e7dd19479..4fd8a542d 100644 --- a/pom.xml +++ b/pom.xml @@ -407,7 +407,8 @@ env-info config properties - docker-build + build/docker + build/podman javaee-like-getting-started scaling service-discovery/stork