Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit 2c8bb34

Browse files
authored
Fixes #69 - Create guide using Piranha Web Profile container image (#70)
1 parent 189787e commit 2c8bb34

File tree

6 files changed

+182
-0
lines changed

6 files changed

+182
-0
lines changed

webprofile/image/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

webprofile/image/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Testing with our container image
3+
4+
See [Test with our container image](https://piranha.cloud/web-profile/guides/image)
5+
for the step by step guide. This repository contains the resulting project for
6+
your reference.

webprofile/image/pom.xml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project
4+
xmlns="http://maven.apache.org/POM/4.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
7+
<modelVersion>4.0.0</modelVersion>
8+
<groupId>cloud.piranha.guides.webprofile</groupId>
9+
<artifactId>docker</artifactId>
10+
<version>1-SNAPSHOT</version>
11+
<packaging>war</packaging>
12+
<name>Testing with our container image</name>
13+
<properties>
14+
<!-- dependencies -->
15+
<jakartaee.version>10.0.0</jakartaee.version>
16+
<junit.version>5.10.0-M1</junit.version>
17+
<!-- plugins -->
18+
<docker-maven-plugin.version>0.43.4</docker-maven-plugin.version>
19+
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
20+
<maven-failsafe-plugin.version>3.0.0</maven-failsafe-plugin.version>
21+
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
22+
<!-- other -->
23+
<java.version>21</java.version>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
</properties>
26+
<dependencies>
27+
<dependency>
28+
<groupId>jakarta.platform</groupId>
29+
<artifactId>jakarta.jakartaee-web-api</artifactId>
30+
<version>${jakartaee.version}</version>
31+
<scope>provided</scope>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.junit.jupiter</groupId>
35+
<artifactId>junit-jupiter-api</artifactId>
36+
<version>${junit.version}</version>
37+
<scope>test</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.junit.jupiter</groupId>
41+
<artifactId>junit-jupiter-engine</artifactId>
42+
<version>${junit.version}</version>
43+
<scope>test</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.junit.jupiter</groupId>
47+
<artifactId>junit-jupiter-params</artifactId>
48+
<version>${junit.version}</version>
49+
<scope>test</scope>
50+
</dependency>
51+
</dependencies>
52+
<build>
53+
<finalName>image</finalName>
54+
<plugins>
55+
<plugin>
56+
<groupId>io.fabric8</groupId>
57+
<artifactId>docker-maven-plugin</artifactId>
58+
<version>${docker-maven-plugin.version}</version>
59+
<configuration>
60+
<images>
61+
<image>
62+
<alias>ocelot-azure-keyvault</alias>
63+
<name>ghcr.io/manorrock/ocelot-azure-keyvault:latest</name>
64+
<build>
65+
<buildx>
66+
<platforms>
67+
<platform>linux/amd64</platform>
68+
<platform>linux/arm64</platform>
69+
</platforms>
70+
</buildx>
71+
<contextDir>${basedir}</contextDir>
72+
<dockerFile>src/main/docker/Dockerfile</dockerFile>
73+
</build>
74+
<run>
75+
<ports>
76+
<port>8080:8080</port>
77+
</ports>
78+
<wait>
79+
<http>
80+
<url>http://localhost:8080/helloworld.html</url>
81+
</http>
82+
<time>20000</time>
83+
</wait>
84+
</run>
85+
</image>
86+
</images>
87+
</configuration>
88+
<executions>
89+
<execution>
90+
<id>start</id>
91+
<phase>pre-integration-test</phase>
92+
<goals>
93+
<goal>build</goal>
94+
<goal>start</goal>
95+
</goals>
96+
</execution>
97+
<execution>
98+
<id>stop</id>
99+
<phase>post-integration-test</phase>
100+
<goals>
101+
<goal>stop</goal>
102+
</goals>
103+
</execution>
104+
</executions>
105+
</plugin>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-compiler-plugin</artifactId>
109+
<version>${maven-compiler-plugin.version}</version>
110+
<configuration>
111+
<release>${java.version}</release>
112+
</configuration>
113+
</plugin>
114+
<plugin>
115+
<groupId>org.apache.maven.plugins</groupId>
116+
<artifactId>maven-failsafe-plugin</artifactId>
117+
<version>${maven-failsafe-plugin.version}</version>
118+
<executions>
119+
<execution>
120+
<goals>
121+
<goal>integration-test</goal>
122+
<goal>verify</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
<plugin>
128+
<groupId>org.apache.maven.plugins</groupId>
129+
<artifactId>maven-war-plugin</artifactId>
130+
<version>${maven-war-plugin.version}</version>
131+
<configuration>
132+
<failOnMissingWebXml>false</failOnMissingWebXml>
133+
</configuration>
134+
</plugin>
135+
</plugins>
136+
</build>
137+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM ghcr.io/piranhacloud/webprofile:23.12.0
2+
USER piranha
3+
COPY target/image.war /home/piranha/ROOT.war
4+
CMD ["java", "-jar", "piranha-dist-webprofile.jar", "--war-file", "ROOT.war"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<title>Hello World</title>
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
</head>
9+
<body>
10+
<div>Hello World!</div>
11+
</body>
12+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package helloworld;
2+
3+
import java.net.URI;
4+
import java.net.http.HttpClient;
5+
import java.net.http.HttpRequest;
6+
import java.net.http.HttpResponse;
7+
import java.net.http.HttpResponse.BodyHandlers;
8+
import static org.junit.jupiter.api.Assertions.assertTrue;
9+
import org.junit.jupiter.api.Test;
10+
11+
class HelloWorldIT {
12+
13+
@Test
14+
void testHelloWorldHtml() throws Exception {
15+
HttpClient client = HttpClient.newHttpClient();
16+
HttpRequest request = HttpRequest
17+
.newBuilder(new URI("http://localhost:8080/helloworld.html"))
18+
.build();
19+
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
20+
assertTrue(response.body().contains("Hello World!"));
21+
}
22+
}

0 commit comments

Comments
 (0)