Skip to content

Commit

Permalink
Cover podman-build extension
Browse files Browse the repository at this point in the history
  • Loading branch information
fedinskiy committed Aug 8, 2024
1 parent b5d2bd6 commit bdb5bb2
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ Also ensures proper integration of SmallRye Config [Secret Keys](https://smallry
### `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.
Expand Down
59 changes: 59 additions & 0 deletions build/podman/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkus.ts.qe</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>podman-build</artifactId>
<packaging>jar</packaging>
<name>Quarkus QE TS: Podman-build</name>
<properties>
<quarkus.container-image.build>true</quarkus.container-image.build>
</properties>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-podman</artifactId>
</dependency>
</dependencies>
<profiles>
<!-- Skipped on Windows when availability of Linux containers is not explicitly declared -->
<profile>
<id>skip-tests-on-windows</id>
<activation>
<os>
<family>windows</family>
</os>
<property>
<name>!linux-containers-available</name>
</property>
</activation>
<properties>
<quarkus.container-image.build>false</quarkus.container-image.build>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
40 changes: 40 additions & 0 deletions build/podman/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -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"

25 changes: 25 additions & 0 deletions build/podman/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 16 additions & 0 deletions build/podman/src/main/java/io/quarkus/ts/docker/HelloResource.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
8 changes: 8 additions & 0 deletions build/podman/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
quarkus.container-image.group=qe
# DON'T remove the spaces that are at the end of quarkus app name
quarkus.application.name=hello-world-app
quarkus.container-image.tag=1.0.0

# native debug configuration
quarkus.native.debug.enabled=true
quarkus.native.additional-build-args=-H:GenerateDebugInfo=1, -H:-SpawnIsolates, -H:DebugInfoSourceCacheRoot=test
38 changes: 38 additions & 0 deletions build/podman/src/test/java/io/quarkus/ts/docker/PodmanBuildIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.ts.docker;

import com.github.dockerjava.api.model.Image;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.utils.DockerUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertTrue;

@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-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");
}
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
<module>config</module>
<module>properties</module>
<module>build/docker</module>
<module>build/podman</module>
<module>javaee-like-getting-started</module>
<module>scaling</module>
<module>service-discovery/stork</module>
Expand Down

0 comments on commit bdb5bb2

Please sign in to comment.