BAEL-4148: Demo app for spring boot and Docker

This commit is contained in:
Michael Pratt
2020-07-11 20:34:36 -06:00
parent c7549ff638
commit a909a79f71
7 changed files with 591 additions and 0 deletions
@@ -0,0 +1,15 @@
# To build, run the following command from the top level project directory:
#
# docker build -f src/main/docker/Dockerfile .
FROM adoptopenjdk:11-jre-hotspot as builder
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM adoptopenjdk:11-jre-hotspot
COPY --from=builder dependencies/ ./
COPY --from=builder snapshot-dependencies/ ./
COPY --from=builder spring-boot-loader/ ./
COPY --from=builder application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
@@ -0,0 +1,13 @@
package com.baeldung.docker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
@@ -0,0 +1,16 @@
package com.baeldung.docker;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public ResponseEntity<String> hello()
{
return ResponseEntity.ok("hello2 ");
}
}