diff --git a/samples/spring-postgres/backend/Dockerfile b/samples/spring-postgres/backend/Dockerfile new file mode 100755 index 0000000..10e0920 --- /dev/null +++ b/samples/spring-postgres/backend/Dockerfile @@ -0,0 +1,12 @@ +FROM maven:3.5-jdk-9 AS build +COPY pom.xml . +RUN mvn --batch-mode dependency:resolve +COPY . . +RUN mvn --batch-mode package +RUN cp target/*jar target/app.jar + +FROM openjdk:9-jre +EXPOSE 8080 +VOLUME /tmp +COPY --from=build target/app.jar app.jar +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] diff --git a/samples/spring-postgres/backend/pom.xml b/samples/spring-postgres/backend/pom.xml new file mode 100755 index 0000000..aeef767 --- /dev/null +++ b/samples/spring-postgres/backend/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + com.company + project + 0.0.1-SNAPSHOT + jar + + New App + My new SpringBoot app + + + org.springframework.boot + spring-boot-starter-parent + 2.0.3.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.session + spring-session-core + + + org.springframework.boot + spring-boot-devtools + + + org.springframework.boot + spring-boot-starter-freemarker + + + org.springframework.boot + spring-boot-starter-test + test + + + org.projectlombok + lombok + + + javax.xml.bind + jaxb-api + 2.3.0 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/samples/spring-postgres/backend/src/main/java/com/company/project/Application.java b/samples/spring-postgres/backend/src/main/java/com/company/project/Application.java new file mode 100755 index 0000000..16b8c45 --- /dev/null +++ b/samples/spring-postgres/backend/src/main/java/com/company/project/Application.java @@ -0,0 +1,16 @@ +package com.company.project; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@EnableAutoConfiguration +@ComponentScan(basePackages = {"com.company.project"}) +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/samples/spring-postgres/backend/src/main/java/com/company/project/controllers/HomeController.java b/samples/spring-postgres/backend/src/main/java/com/company/project/controllers/HomeController.java new file mode 100755 index 0000000..966839d --- /dev/null +++ b/samples/spring-postgres/backend/src/main/java/com/company/project/controllers/HomeController.java @@ -0,0 +1,16 @@ +package com.company.project.controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +public class HomeController { + + @GetMapping("/") + public String showHome(String name, Model model) { + return "home"; + } + +} diff --git a/samples/spring-postgres/backend/src/main/resources/application.properties b/samples/spring-postgres/backend/src/main/resources/application.properties new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/samples/spring-postgres/backend/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/samples/spring-postgres/backend/src/main/resources/templates/home.ftl b/samples/spring-postgres/backend/src/main/resources/templates/home.ftl new file mode 100755 index 0000000..daba182 --- /dev/null +++ b/samples/spring-postgres/backend/src/main/resources/templates/home.ftl @@ -0,0 +1,9 @@ + + + + Getting Started: Serving Web Content + + + +

Hello from Docker!

+ diff --git a/samples/spring-postgres/db/password.txt b/samples/spring-postgres/db/password.txt new file mode 100644 index 0000000..dda70f4 --- /dev/null +++ b/samples/spring-postgres/db/password.txt @@ -0,0 +1 @@ +db-wrz2z \ No newline at end of file diff --git a/samples/spring-postgres/docker-compose.yaml b/samples/spring-postgres/docker-compose.yaml new file mode 100644 index 0000000..307a6a7 --- /dev/null +++ b/samples/spring-postgres/docker-compose.yaml @@ -0,0 +1,21 @@ +version: "3.7" +services: + backend: + build: backend + ports: + - 80:8080 + db: + environment: + POSTGRES_DB: example + POSTGRES_PASSWORD_FILE: /run/secrets/db-password + image: postgres + restart: always + secrets: + - db-password + volumes: + - db-data:/var/lib/postgresql/data +volumes: + db-data: {} +secrets: + db-password: + file: db/password.txt