-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reading Jib configuration for ports (#1229)
* Ensure we use Jib configuration for ports * WIP: use Jackson to parse Jib configuration * Test current Jib configuration parsing * Implement service using Jackson * Parse ports * Add functional test * Add functional test * Align Jackson versions
- Loading branch information
1 parent
b168e83
commit fc91a28
Showing
26 changed files
with
817 additions
and
126 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
micronaut-maven-integration-tests/src/it/issue1218/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM ghcr.io/graalvm/native-image-community:17-ol9 AS builder | ||
WORKDIR /home/app | ||
|
||
COPY classes /home/app/classes | ||
COPY dependency/* /home/app/libs/ | ||
COPY graalvm-reachability-metadat[a] /home/app/graalvm-reachability-metadata | ||
COPY nativ[e]/generated /home/app/ | ||
COPY *.args /home/app/graalvm-native-image.args | ||
RUN native-image @/home/app/graalvm-native-image.args -H:Class=io.micronaut.build.examples.Application -H:Name=application -cp "/home/app/libs/*:/home/app/classes/" | ||
|
||
FROM cgr.dev/chainguard/wolfi-base:latest | ||
COPY --from=builder /home/app/application /app/application | ||
|
||
EXPOSE 8080 8081 | ||
ENTRYPOINT ["/app/application"] |
2 changes: 2 additions & 0 deletions
2
micronaut-maven-integration-tests/src/it/issue1218/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals = -ntp mn:dockerfile -Dpackaging=docker-native compile docker:build docker:start docker:stop | ||
invoker.os.family = !windows |
156 changes: 156 additions & 0 deletions
156
micronaut-maven-integration-tests/src/it/issue1218/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<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> | ||
<groupId>io.micronaut.build.examples</groupId> | ||
<artifactId>issue1218</artifactId> | ||
<version>0.1</version> | ||
<packaging>${packaging}</packaging> | ||
|
||
<parent> | ||
<groupId>io.micronaut.platform</groupId> | ||
<artifactId>micronaut-parent</artifactId> | ||
<version>@it.micronaut.version@</version> | ||
</parent> | ||
|
||
<properties> | ||
<micronaut.version>@it.micronaut.version@</micronaut.version> | ||
<micronaut-maven-plugin.version>@project.version@</micronaut-maven-plugin.version> | ||
<exec.mainClass>io.micronaut.build.examples.Application</exec.mainClass> | ||
<maven.native.plugin.version>@native-maven-plugin.version@</maven.native.plugin.version> | ||
<packaging>jar</packaging> | ||
<micronaut.runtime>netty</micronaut.runtime> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-server-netty</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.serde</groupId> | ||
<artifactId>micronaut-serde-jackson</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.yaml</groupId> | ||
<artifactId>snakeyaml</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-client</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.test</groupId> | ||
<artifactId>micronaut-test-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.micronaut.maven</groupId> | ||
<artifactId>micronaut-maven-plugin</artifactId> | ||
<version>${micronaut-maven-plugin.version}</version> | ||
<configuration> | ||
<nativeImageBuildArgs>-Ob</nativeImageBuildArgs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<!-- Uncomment to enable incremental compilation --> | ||
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> --> | ||
<annotationProcessorPaths combine.children="append"> | ||
<path> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-validation</artifactId> | ||
<version>${micronaut.core.version}</version> | ||
</path> | ||
<path> | ||
<groupId>io.micronaut.serde</groupId> | ||
<artifactId>micronaut-serde-processor</artifactId> | ||
<version>${micronaut.serialization.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-inject</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</path> | ||
</annotationProcessorPaths> | ||
<compilerArgs> | ||
<arg>-Amicronaut.processing.group=io.micronaut.build.examples</arg> | ||
<arg>-Amicronaut.processing.module=${project.artifactId}</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>jib-maven-plugin</artifactId> | ||
<configuration> | ||
<to> | ||
<image>alvarosanchez/${project.artifactId}:${project.version}</image> | ||
</to> | ||
<container> | ||
<ports> | ||
<port>8080</port> | ||
<port>8081</port> | ||
</ports> | ||
</container> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.45.1</version> | ||
<configuration> | ||
<showLogs>true</showLogs> | ||
<outputDirectory>${java.io.tmpdir}</outputDirectory> | ||
<verbose>true</verbose> | ||
<images> | ||
<image> | ||
<name>alvarosanchez/${project.artifactId}:${project.version}</name> | ||
<build> | ||
<dockerFileDir>${project.build.directory}</dockerFileDir> | ||
</build> | ||
<run> | ||
<wait> | ||
<log>Startup completed in</log> | ||
<time>20000</time> | ||
</wait> | ||
</run> | ||
</image> | ||
</images> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
10 changes: 10 additions & 0 deletions
10
...gration-tests/src/it/issue1218/src/main/java/io/micronaut/build/examples/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.micronaut.build.examples; | ||
|
||
import io.micronaut.runtime.Micronaut; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
Micronaut.run(Application.class); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
micronaut-maven-integration-tests/src/it/issue1218/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
micronaut: | ||
application: | ||
name: issue1218 |
15 changes: 15 additions & 0 deletions
15
micronaut-maven-integration-tests/src/it/issue1218/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<withJansi>false</withJansi> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
21 changes: 21 additions & 0 deletions
21
...ion-tests/src/it/issue1218/src/test/java/io/micronaut/build/examples/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.micronaut.build.examples; | ||
|
||
import io.micronaut.runtime.EmbeddedApplication; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
@MicronautTest | ||
public class ApplicationTest { | ||
|
||
@Inject | ||
EmbeddedApplication application; | ||
|
||
@Test | ||
void testItWorks() { | ||
Assertions.assertTrue(application.isRunning()); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
micronaut-maven-integration-tests/src/it/issue1218/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
File dockerfile = new File("$basedir/target", "Dockerfile") | ||
File expectedDockerfile = new File(basedir, "Dockerfile") | ||
String expectedDockerfileText = expectedDockerfile.text.replace("17", "${System.getProperty("java.specification.version")}") | ||
|
||
assert dockerfile.text == expectedDockerfileText | ||
|
||
File log = new File(basedir, 'build.log') | ||
assert log.exists() | ||
assert log.text.contains("io.micronaut.runtime.Micronaut - Startup completed") | ||
assert log.text.contains("EXPOSE 8080 8081") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
micronaut-maven-jib-integration/src/main/java/io/micronaut/maven/jib/JibConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2017-2024 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.maven.jib; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** | ||
* Represents the Jib plugin configuration. | ||
* | ||
* @param from The from configuration. | ||
* @param to The to configuration. | ||
* @param container The container configuration. | ||
* @since 4.7.0 | ||
*/ | ||
public record JibConfiguration(Optional<FromConfiguration> from, Optional<ToConfiguration> to, Optional<ContainerConfiguration> container) { | ||
|
||
/** | ||
* Represents the authentication configuration. | ||
* | ||
* @param username The username. | ||
* @param password The password. | ||
*/ | ||
public record AuthConfiguration(Optional<String> username, Optional<String> password) { } | ||
|
||
/** | ||
* Represents the from configuration. | ||
* | ||
* @param image The image. | ||
* @param auth The authentication configuration. | ||
*/ | ||
public record FromConfiguration(Optional<String> image, Optional<AuthConfiguration> auth) { } | ||
|
||
/** | ||
* Represents the to configuration. | ||
* | ||
* @param image The image. | ||
* @param tags The tags. | ||
* @param auth The authentication configuration. | ||
*/ | ||
public record ToConfiguration(Optional<String> image, Set<String> tags, Optional<AuthConfiguration> auth) { } | ||
|
||
/** | ||
* Represents the container configuration. | ||
* | ||
* @param workingDirectory The working directory. | ||
* @param ports The ports. | ||
* @param args The arguments. | ||
* @param labels The labels. | ||
*/ | ||
public record ContainerConfiguration(Optional<String> workingDirectory, Set<String> ports, List<String> args, Set<String> labels) { } | ||
} |
Oops, something went wrong.