mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-25 16:22:35 +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
|
||||
|
||||
.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"
|
||||
version = "0.0.1-SNAPSHOT"
|
||||
version = "single-version"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
@@ -69,4 +69,3 @@ tasks.test {
|
||||
tasks.jacocoTestReport {
|
||||
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`
|
||||
* `postgresql` версии `14`
|
||||
* `kafka` без авторизации
|
||||
* `docker` + `compose` (для тестов)
|
||||
* `docker` + `compose`
|
||||
|
||||
## Доступные команды
|
||||
|
||||
@@ -20,3 +20,15 @@ Demo приложение для изучения языка `kotlin` и фре
|
||||
```shell
|
||||
./gradlew bootRun
|
||||
```
|
||||
|
||||
## Запуск с docker-compose
|
||||
|
||||
Перед каждым запуском необходимо собрать приложение:
|
||||
```shell
|
||||
./gradlew assemble
|
||||
```
|
||||
|
||||
Затем можно запускать контейнер:
|
||||
```shell
|
||||
docker compose up -d
|
||||
```
|
||||
@@ -3,20 +3,20 @@ spring:
|
||||
application:
|
||||
name: Demo
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/demo?currentSchema=public
|
||||
username: postgres
|
||||
password: postgres
|
||||
url: jdbc:postgresql://${DB_URL:localhost:5432}/${DB_NAME:demo}?currentSchema=${DB_SCHEMA:public}
|
||||
username: ${DB_USERNAME:postgres}
|
||||
password: ${DB_PASSWORD:postgres}
|
||||
driver-class-name: org.postgresql.Driver
|
||||
hikari:
|
||||
schema: public
|
||||
schema: ${DB_SCHEMA:public}
|
||||
flyway: #flyway automatically uses the datasource from the application to connect to the DB
|
||||
enabled: true # enables flyway database migration
|
||||
locations: classpath:db/migration/structure, classpath:db/migration/data # the location where flyway should look for migration scripts
|
||||
validate-on-migrate: true
|
||||
default-schema: public
|
||||
default-schema: ${DB_SCHEMA:public}
|
||||
|
||||
kafka:
|
||||
bootstrap-servers: localhost:9095
|
||||
bootstrap-servers: ${KAFKA_SERVERS:localhost:9095}
|
||||
producer:
|
||||
product:
|
||||
default-sync-topic: demo-product-sync
|
||||
|
||||
Reference in New Issue
Block a user