mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-26 00:32:34 +03:00
dockerize application
This commit is contained in:
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!build/libs/
|
||||||
7
.env.example
Normal file
7
.env.example
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
DB_URL=localhost:5432
|
||||||
|
DB_NAME=demo
|
||||||
|
DB_SCHEMA=public
|
||||||
|
DB_USERNAME=postgres
|
||||||
|
DB_PASSWORD=postgres
|
||||||
|
|
||||||
|
KAFKA_SERVERS=localhost:9095
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -30,3 +30,6 @@ out/
|
|||||||
|
|
||||||
### Kotlin ###
|
### Kotlin ###
|
||||||
.kotlin
|
.kotlin
|
||||||
|
|
||||||
|
.env
|
||||||
|
docker-compose.override.yml
|
||||||
|
|||||||
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM openjdk:17-jdk-slim
|
||||||
|
COPY --chmod=777 build/libs/demo-single-version.jar /application/demo.jar
|
||||||
|
CMD ["java", "-jar", "/application/demo.jar"]
|
||||||
@@ -11,7 +11,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.example"
|
group = "com.example"
|
||||||
version = "0.0.1-SNAPSHOT"
|
version = "single-version"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
@@ -69,4 +69,3 @@ tasks.test {
|
|||||||
tasks.jacocoTestReport {
|
tasks.jacocoTestReport {
|
||||||
dependsOn(tasks.test) // tests are required to run before generating the report
|
dependsOn(tasks.test) // tests are required to run before generating the report
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
services:
|
||||||
|
demo:
|
||||||
|
image: localhost/spring-boot-demo:latest
|
||||||
|
build:
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
context: .
|
||||||
|
environment:
|
||||||
|
DB_URL: $DB_URL
|
||||||
|
DB_NAME: $DB_NAME
|
||||||
|
DB_SCHEMA: $DB_SCHEMA
|
||||||
|
DB_USERNAME: $DB_USERNAME
|
||||||
|
DB_PASSWORD: $DB_PASSWORD
|
||||||
|
KAFKA_SERVERS: $KAFKA_SERVERS
|
||||||
|
expose:
|
||||||
|
- 8080
|
||||||
|
- 8081
|
||||||
14
readme.md
14
readme.md
@@ -7,7 +7,7 @@ Demo приложение для изучения языка `kotlin` и фре
|
|||||||
* `jdk` версии `17`
|
* `jdk` версии `17`
|
||||||
* `postgresql` версии `14`
|
* `postgresql` версии `14`
|
||||||
* `kafka` без авторизации
|
* `kafka` без авторизации
|
||||||
* `docker` + `compose` (для тестов)
|
* `docker` + `compose`
|
||||||
|
|
||||||
## Доступные команды
|
## Доступные команды
|
||||||
|
|
||||||
@@ -20,3 +20,15 @@ Demo приложение для изучения языка `kotlin` и фре
|
|||||||
```shell
|
```shell
|
||||||
./gradlew bootRun
|
./gradlew bootRun
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Запуск с docker-compose
|
||||||
|
|
||||||
|
Перед каждым запуском необходимо собрать приложение:
|
||||||
|
```shell
|
||||||
|
./gradlew assemble
|
||||||
|
```
|
||||||
|
|
||||||
|
Затем можно запускать контейнер:
|
||||||
|
```shell
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
@@ -3,20 +3,20 @@ spring:
|
|||||||
application:
|
application:
|
||||||
name: Demo
|
name: Demo
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:postgresql://localhost:5432/demo?currentSchema=public
|
url: jdbc:postgresql://${DB_URL:localhost:5432}/${DB_NAME:demo}?currentSchema=${DB_SCHEMA:public}
|
||||||
username: postgres
|
username: ${DB_USERNAME:postgres}
|
||||||
password: postgres
|
password: ${DB_PASSWORD:postgres}
|
||||||
driver-class-name: org.postgresql.Driver
|
driver-class-name: org.postgresql.Driver
|
||||||
hikari:
|
hikari:
|
||||||
schema: public
|
schema: ${DB_SCHEMA:public}
|
||||||
flyway: #flyway automatically uses the datasource from the application to connect to the DB
|
flyway: #flyway automatically uses the datasource from the application to connect to the DB
|
||||||
enabled: true # enables flyway database migration
|
enabled: true # enables flyway database migration
|
||||||
locations: classpath:db/migration/structure, classpath:db/migration/data # the location where flyway should look for migration scripts
|
locations: classpath:db/migration/structure, classpath:db/migration/data # the location where flyway should look for migration scripts
|
||||||
validate-on-migrate: true
|
validate-on-migrate: true
|
||||||
default-schema: public
|
default-schema: ${DB_SCHEMA:public}
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
bootstrap-servers: localhost:9095
|
bootstrap-servers: ${KAFKA_SERVERS:localhost:9095}
|
||||||
producer:
|
producer:
|
||||||
product:
|
product:
|
||||||
default-sync-topic: demo-product-sync
|
default-sync-topic: demo-product-sync
|
||||||
|
|||||||
Reference in New Issue
Block a user