diff options
author | terminaldweller <thabogre@gmail.com> | 2022-03-16 05:47:37 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-03-16 05:47:37 +0000 |
commit | 1d05064b590d119065495a6d9ce30ae2d4aab05d (patch) | |
tree | b72546f16c7952060ea903b39ce19933f22fe884 | |
parent | added a new doc class, added self-signed certs to the docker image (diff) | |
download | mdrtl-1d05064b590d119065495a6d9ce30ae2d4aab05d.tar.gz mdrtl-1d05064b590d119065495a6d9ce30ae2d4aab05d.zip |
wip
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | docker-compose.yaml | 4 | ||||
-rw-r--r-- | src/main/java/com/terminaldweller/doc/DocController.java | 24 | ||||
-rw-r--r-- | src/main/java/com/terminaldweller/doc/DocService.java | 12 | ||||
-rw-r--r-- | src/main/java/com/terminaldweller/main/MainApplication.java | 10 | ||||
-rw-r--r-- | src/main/resources/application.properties | 7 |
6 files changed, 52 insertions, 7 deletions
@@ -4,7 +4,6 @@ WORKDIR /certs RUN openssl req -nodes -new -x509 -subj="/C=US/ST=Denial/L=springfield/O=Dis/CN=localhost" -keyout server.key -out server.cert FROM gradle:7.3.3-jdk11-alpine AS builder -COPY --from=certbuilder /certs /certs WORKDIR /home/springapp COPY --chown=gradle:gradle ./gradlew /home/springapp/ COPY --chown=gradle:gradle ./settings.gradle.kts /home/springapp/ @@ -14,6 +13,7 @@ COPY --chown=gradle:gradle ./src /home/springapp/src RUN gradle bootJar --no-daemon FROM eclipse-temurin:11-jre-alpine +COPY --from=certbuilder /certs /certs WORKDIR /springapp COPY --from=builder /home/springapp/build/libs/src.jar ./src.jar ENTRYPOINT ["java", "-jar", "/springapp/src.jar"] diff --git a/docker-compose.yaml b/docker-compose.yaml index f92cc94..a357384 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,6 +10,8 @@ services: - springnet cap_drop: - ALL + environment: + - DOCKER_DEPLOYMENT_TYPE=deployment postgres: image: postgres:14-alpine networks: @@ -17,7 +19,7 @@ services: volumes: - db-data:/var/lib/postgresql/14/ ports: - - "5432:5432" + - "127.0.0.1:5432:5432" environment: - POSTGRES_PASSWORD_FILE=/run/secrets/pg_pass_secret - POSTGRES_USER_FILE=/run/secrets/pg_user_secret diff --git a/src/main/java/com/terminaldweller/doc/DocController.java b/src/main/java/com/terminaldweller/doc/DocController.java new file mode 100644 index 0000000..564f37c --- /dev/null +++ b/src/main/java/com/terminaldweller/doc/DocController.java @@ -0,0 +1,24 @@ +package com.terminaldweller.doc; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** The document controller class. */ +@RestController +@RequestMapping(path = "api/v1/doc") +public class DocController { + private final DocService docService; + + @Autowired + public DocController(DocService docService) { + this.docService = docService; + } + + @GetMapping + public List<Doc> getDocs() { + return docService.getDocs(); + } +} diff --git a/src/main/java/com/terminaldweller/doc/DocService.java b/src/main/java/com/terminaldweller/doc/DocService.java new file mode 100644 index 0000000..4aee30b --- /dev/null +++ b/src/main/java/com/terminaldweller/doc/DocService.java @@ -0,0 +1,12 @@ +package com.terminaldweller.doc; + +import java.util.List; +import org.springframework.stereotype.Service; + +/** The document service class. */ +@Service +public class DocService { + public List<Doc> getDocs() { + return List.of(new Doc(1L, "loco", 0L)); + } +} diff --git a/src/main/java/com/terminaldweller/main/MainApplication.java b/src/main/java/com/terminaldweller/main/MainApplication.java index c577139..146dbcf 100644 --- a/src/main/java/com/terminaldweller/main/MainApplication.java +++ b/src/main/java/com/terminaldweller/main/MainApplication.java @@ -9,11 +9,6 @@ import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class MainApplication { - @RequestMapping("/") - public String home() { - return "Hello Docker World"; - } - /** * just a dummy main. * @@ -22,4 +17,9 @@ public class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class, args); } + + @RequestMapping("/") + public String home() { + return "Hello Docker World"; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..547f233 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.datasource.url=jdbc:postgresql://postgres:5432 +spring.datasource.username= +spring.datasource.password= +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.properties.hibernate.format_sql=true |