From 218fa6553e3c0e167484f27487438e4309acd638 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Mon, 15 Jan 2024 21:08:44 +0300 Subject: [PATCH] Add postgresql support to pom, create sample stack 4 docker --- .gitignore | 6 ++-- .vscode/launch.json | 12 +++++++- docker/deloyment-example/README.MD | 5 +++ docker/deloyment-example/build/Dockerfile | 9 ++++++ docker/deloyment-example/docker-compose.yml | 34 +++++++++++++++++++++ pom.xml | 6 ++++ src/main/resources/application-prod.yml | 21 +++++++++++++ 7 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 docker/deloyment-example/README.MD create mode 100644 docker/deloyment-example/build/Dockerfile create mode 100644 docker/deloyment-example/docker-compose.yml create mode 100644 src/main/resources/application-prod.yml diff --git a/.gitignore b/.gitignore index 627b66f..8c222c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ -postgres/docker-compose.yml +docker/deloyment-example/files/library/* +docker/deloyment-example/files/postgresql/* +docker/deloyment-example/files/root/* target/ -lib/ \ No newline at end of file +lib/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 5d12f52..f093494 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,13 +2,23 @@ "configurations": [ { "type": "java", - "name": "Spring Boot-MarinescoApplication", + "name": "Marinesco DEV", "request": "launch", "cwd": "${workspaceFolder}", "mainClass": "ru.redrise.marinesco.MarinescoApplication", "projectName": "marinesco", "args": "", "envFile": "${workspaceFolder}/.env" + }, + { + "type": "java", + "name": "Marinesco PROD", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "ru.redrise.marinesco.MarinescoApplication", + "projectName": "marinesco", + "args": "--spring.profiles.active=prod", + "envFile": "${workspaceFolder}/.env" } ] } \ No newline at end of file diff --git a/docker/deloyment-example/README.MD b/docker/deloyment-example/README.MD new file mode 100644 index 0000000..51afc41 --- /dev/null +++ b/docker/deloyment-example/README.MD @@ -0,0 +1,5 @@ +### How to +1. Place `marinesco.jar` to `files/root/`. Rename artifact if needed. +2. Extract `inpx`-file-containing folder into `files/library/` +3. Optionally remove `pgadmin` section from `docker-compose.yml` file +4. Run via `docker compose up` diff --git a/docker/deloyment-example/build/Dockerfile b/docker/deloyment-example/build/Dockerfile new file mode 100644 index 0000000..6f6e5aa --- /dev/null +++ b/docker/deloyment-example/build/Dockerfile @@ -0,0 +1,9 @@ +FROM openjdk:21-jdk-slim + +ENV TZ=Europe/Moscow + +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +WORKDIR /root + +CMD java -jar marinesco.jar \ No newline at end of file diff --git a/docker/deloyment-example/docker-compose.yml b/docker/deloyment-example/docker-compose.yml new file mode 100644 index 0000000..258a727 --- /dev/null +++ b/docker/deloyment-example/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.1' + +services: + marinesco: + build: ./build + image: loper:marinesco + links: + - postgres + ports: + - 80:8080 + volumes: + - ./files/root:/root + - ./files/library:/library + environment: + - SPRING_PROFILES_ACTIVE=prod + logging: + driver: syslog + postgres: + image: postgres + volumes: + - ./files/postgresql:/var/lib/postgresql + environment: + - POSTGRES_USER=mari + - POSTGRES_PASSWORD=example + - POSTGRES_DB=marinesco + pgadmin: + image: dpage/pgadmin4 + links: + - postgres + ports: + - 3334:80 + environment: + - PGADMIN_DEFAULT_EMAIL=root@srv.lan + - PGADMIN_DEFAULT_PASSWORD=example diff --git a/pom.xml b/pom.xml index 1fb3a06..d545cdf 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,12 @@ true + + + org.postgresql + postgresql + runtime + diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..b6b221a --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,21 @@ +spring: + thymeleaf: + cache: true + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://postgres:5432/marinesco + username: mari + password: example + jpa: + properties: + hibernate: + database-platform: org.hibernate.dialect.PostgreSQL94Dialect + hibernate: + ddl-auto: update +logging: + level: + org: + springframework: INFO +marinesco: + library: + filesLocation: "/library" \ No newline at end of file