add docker image build and run
This commit is contained in:
parent
a2f3e62d7d
commit
8b6fc42ce9
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
target/
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.PHONY: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
./mvnw compile
|
||||||
|
|
||||||
|
run:
|
||||||
|
./mvnw spring-boot:run
|
||||||
|
|
||||||
|
debug:
|
||||||
|
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
|
||||||
|
|
||||||
|
docker-build:
|
||||||
|
./mvnw compile com.google.cloud.tools:jib-maven-plugin:2.5.2:build
|
||||||
|
|
||||||
|
docker-run:
|
||||||
|
docker run --rm -d -p 8080:8080 docker.registry:5000/wikiproject:latest
|
78
pom.xml
78
pom.xml
@ -1,39 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<!-- spring-boot -->
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.3.2.RELEASE</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<groupId>fr.antoine-roux</groupId>
|
<groupId>fr.antoine-roux</groupId>
|
||||||
<artifactId>wikiProject</artifactId>
|
<artifactId>wikiProject</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
<name>wikiProject</name>
|
<name>wikiProject</name>
|
||||||
<description>project use wikipedia streaming api https://stream.wikimedia.org/?doc#/Streams/get_v2_stream_test</description>
|
<description>project use wikipedia streaming api https://stream.wikimedia.org/?doc#/Streams/get_v2_stream_test
|
||||||
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>1.0-SNAPSHOT</revision>
|
<revision>1.0-SNAPSHOT</revision>
|
||||||
<java.version>14</java.version>
|
<java.version>14</java.version>
|
||||||
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
|
|
||||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||||
|
<jib-maven-plugin.version>2.5.2</jib-maven-plugin.version>
|
||||||
|
<spring-boot.run.jvmArguments/>
|
||||||
|
<application.port>8080</application.port>
|
||||||
|
<resource.delimiter>^</resource.delimiter>
|
||||||
|
<enable-preview.jvmFlag>--enable-preview</enable-preview.jvmFlag>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<!-- spring-boot -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- spring-boot -->
|
<!-- spring-boot -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -64,13 +59,50 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<jvmArguments>${enable-preview.jvmFlag} ${spring-boot.run.jvmArguments}</jvmArguments>
|
||||||
|
<layers>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</layers>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!-- https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin#authentication-methods -->
|
||||||
|
<groupId>com.google.cloud.tools</groupId>
|
||||||
|
<artifactId>jib-maven-plugin</artifactId>
|
||||||
|
<version>${jib-maven-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<from>
|
||||||
|
<!-- <image>adoptopenjdk:14.0.2_8-jdk-openj9-0.21.0</image> -->
|
||||||
|
<image>adoptopenjdk:14-jdk-openj9</image>
|
||||||
|
<!-- <image>adoptopenjdk:14.0.2_8-jdk-hotspot</image> -->
|
||||||
|
<!-- <image>adoptopenjdk:14-jdk-hotspot</image> -->
|
||||||
|
</from>
|
||||||
|
<to>
|
||||||
|
<image>docker.registry:5000/wikiproject</image>
|
||||||
|
</to>
|
||||||
|
<container>
|
||||||
|
<jvmFlags>
|
||||||
|
<jvmFlag>${enable-preview.jvmFlag}</jvmFlag>
|
||||||
|
<jvmFlag>-Xms512m</jvmFlag>
|
||||||
|
</jvmFlags>
|
||||||
|
<ports>
|
||||||
|
<port>${application.port}</port>
|
||||||
|
</ports>
|
||||||
|
<format>OCI</format>
|
||||||
|
</container>
|
||||||
|
<allowInsecureRegistries>true</allowInsecureRegistries>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<release>${java.version}</release>
|
<release>${java.version}</release>
|
||||||
<compilerArgs>--enable-preview</compilerArgs>
|
<compilerArgs>${enable-preview.jvmFlag}</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package tk.antoine_roux.wiki;
|
package tk.antoine_roux.wiki;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -9,22 +10,29 @@ import org.springframework.web.servlet.function.ServerResponse;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class
|
* Main class
|
||||||
* program input
|
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
// force spring application to not use glibc or any non jdk code which is bad for graalvm
|
||||||
|
@SpringBootApplication(proxyBeanMethods = false)
|
||||||
public class MainLauncher {
|
public class MainLauncher {
|
||||||
|
|
||||||
/*
|
@Value("${wikiproject.basePath}")
|
||||||
* entry point for our application
|
private String basePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entrypoint for application
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(MainLauncher.class, args);
|
SpringApplication.run(MainLauncher.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing declaration
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RouterFunction<ServerResponse> routes() {
|
public RouterFunction<ServerResponse> routes() {
|
||||||
return RouterFunctions.route()
|
return RouterFunctions.route()
|
||||||
.GET("/toto", serverRequest -> ServerResponse.ok().body("hello world !"))
|
.GET(this.basePath + "/hello", serverRequest ->
|
||||||
.build();
|
ServerResponse.ok().body("Hello world !")
|
||||||
|
).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ spring.main.banner-mode=off
|
|||||||
spring.main.lazy-initialization=true
|
spring.main.lazy-initialization=true
|
||||||
spring.output.ansi.enabled=ALWAYS
|
spring.output.ansi.enabled=ALWAYS
|
||||||
|
|
||||||
server.port=8081
|
server.port=^application.port^
|
||||||
|
|
||||||
wikiproject.basePath=/wikiproject
|
wikiproject.basePath=/wikiproject
|
||||||
|
Loading…
Reference in New Issue
Block a user