diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cf4f641 --- /dev/null +++ b/Makefile @@ -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 diff --git a/pom.xml b/pom.xml index 21c1e8b..6c4010a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,39 +1,34 @@ - 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.3.2.RELEASE + + fr.antoine-roux wikiProject ${revision} wikiProject - project use wikipedia streaming api https://stream.wikimedia.org/?doc#/Streams/get_v2_stream_test + project use wikipedia streaming api https://stream.wikimedia.org/?doc#/Streams/get_v2_stream_test + 1.0-SNAPSHOT 14 - 2.3.2.RELEASE 3.8.1 + 2.5.2 + + 8080 + ^ + --enable-preview - - - - - org.springframework.boot - spring-boot-starter-parent - ${spring-boot.version} - pom - import - - - org.springframework.boot - spring-boot-starter - ${spring-boot.version} - - - @@ -64,16 +59,53 @@ + + org.springframework.boot + spring-boot-maven-plugin + + ${enable-preview.jvmFlag} ${spring-boot.run.jvmArguments} + + true + + + + + + com.google.cloud.tools + jib-maven-plugin + ${jib-maven-plugin.version} + + + + adoptopenjdk:14-jdk-openj9 + + + + + docker.registry:5000/wikiproject + + + + ${enable-preview.jvmFlag} + -Xms512m + + + ${application.port} + + OCI + + true + + org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} ${java.version} - --enable-preview + ${enable-preview.jvmFlag} - \ No newline at end of file + diff --git a/src/main/java/tk/antoine_roux/wiki/MainLauncher.java b/src/main/java/tk/antoine_roux/wiki/MainLauncher.java index 06b95ed..31c634d 100644 --- a/src/main/java/tk/antoine_roux/wiki/MainLauncher.java +++ b/src/main/java/tk/antoine_roux/wiki/MainLauncher.java @@ -1,5 +1,6 @@ package tk.antoine_roux.wiki; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -9,22 +10,29 @@ import org.springframework.web.servlet.function.ServerResponse; /** * 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 { - /* - * entry point for our application + @Value("${wikiproject.basePath}") + private String basePath; + + /** + * Entrypoint for application */ public static void main(String[] args) { SpringApplication.run(MainLauncher.class, args); } + /** + * Routing declaration + */ @Bean public RouterFunction routes() { return RouterFunctions.route() - .GET("/toto", serverRequest -> ServerResponse.ok().body("hello world !")) - .build(); + .GET(this.basePath + "/hello", serverRequest -> + ServerResponse.ok().body("Hello world !") + ).build(); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c9d053e..c177a09 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,6 +2,6 @@ spring.main.banner-mode=off spring.main.lazy-initialization=true spring.output.ansi.enabled=ALWAYS -server.port=8081 +server.port=^application.port^ wikiproject.basePath=/wikiproject