Skip to content

Commit 131aaff

Browse files
committed
feat: spting boot support for docker compose and version update
1 parent 5d4b968 commit 131aaff

File tree

11 files changed

+2622
-34
lines changed

11 files changed

+2622
-34
lines changed

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ the local development setup.
1111

1212
## Module Information
1313

14-
**ss-api** : It contains utilities like constants, dtos, validators, utility classes. This will be published as a package and this can be used by other Java projects as a depedency
14+
**ss-api** : It contains utilities like constants, dtos, validators, utility classes. This will be published as a package and this can be used by other Java projects as a depedency
1515

1616
**ss-dao** : It contains database entities and repositories.
1717

@@ -25,35 +25,31 @@ the local development setup.
2525

2626
| Area | Tool | Download Link | Comment |
2727
|----------|----------|-------------------------------------------------|---------------------------------------------------------------------------------------------------|
28-
| IDE | IntelliJ | https://www.jetbrains.com/idea/download/ | Additionally the [envfile plugin](https://plugins.jetbrains.com/plugin/7861-envfile) is suggested |
28+
| IDE | IntelliJ | https://www.jetbrains.com/idea/download/ | Additionally the [envfile plugin](https://plugins.jetbrains.com/plugin/7861-envfile) is suggested |
2929
| Build | Gradle | https://gradle.org/install/ |
3030
| Runtime | Docker | https://www.docker.com/products/docker-desktop/ | |
3131
| Database | DBeaver | https://dbeaver.io/ |
3232
| IAM | Keycloak | https://www.keycloak.org/ | |
3333

3434
## Local Development Setup
3535

36-
1. Run keycloak and database server
37-
2. Import realm file [app-test-realm.json](ss-web%2Fsrc%2Ftest%2Fresources%2Fapp-test-realm.json)
38-
3. Update your env variable in application.yaml file
39-
4. Run [MainApplication.java](ss-web%2Fsrc%2Fmain%2Fjava%2Fss%2Fmod%2Fdemo%2FMainApplication.java)
40-
in IDE
41-
5. Open API doc on http://localhost:8080
42-
6. Click on Authorize on swagger UI and on the dialog click again on Authorize.
43-
7. Login with username=valid-user and password=password
36+
1. Run [MainApplication.java](ss-web%2Fsrc%2Fmain%2Fjava%2Fss%2Fmod%2Fdemo%2FMainApplication.java) in IDE. It will up database and keycloak using docker compose(ref: [Spring boot support for docker compose](https://spring.io/blog/2023/06/21/docker-compose-support-in-spring-boot-3-1))
37+
2. Open API doc on http://localhost:8080/api/app/ui/swagger-ui/index.html
38+
3. Click on Authorize on swagger UI and on the dialog click again on Authorize.
39+
4. Login with username=valid-user and password=password
4440

4541
## Build application locally
4642

4743
Build with test cases
4844

4945
```
50-
./gradlew build
46+
./gradlew build
5147
```
5248

5349
Build without test cases
5450

5551
```
56-
./gradlew build -i -x test
52+
./gradlew build -i -x test
5753
```
5854

5955
## Test Coverage
@@ -66,7 +62,7 @@ The generated HTML report can be found under `jacoco-report/html/`
6662
To generate the report run the command
6763

6864
```
69-
./gradlew jacocoTestReport
65+
./gradlew testCodeCoverageReport
7066
```
7167

7268
To check the coverage run the command
@@ -106,8 +102,8 @@ This process ensures that any issues with the database schema are resolved by re
106102

107103
| name | description | default value |
108104
|--------------------------------|-------------------------------------------------|----------------------------|
109-
| APP_PORT | port number of application | 8080 |
110-
| SECURITY_ENABLE | To keep spring security enable/disable | true |
105+
| APP_PORT | port number of application | 8080 |
106+
| SECURITY_ENABLE | To keep spring security enable/disable | true |
111107
| KEYCLOAK_REALM_NAME | Realm name of keycloak | SWD |
112108
| KEYCLOAK_CLIENT_ID | Keycloak public client id | pb_backend |
113109
| KEYCLOAK_ROLE_CLIENT_ID | Keycloak private client id | pb_backend |

build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,22 @@ subprojects {
3636

3737
tasks.named('test') {
3838
useJUnitPlatform()
39+
finalizedBy jacocoTestReport
40+
testLogging {
41+
events("passed", "skipped", "failed")
42+
}
3943
}
4044

45+
jacocoTestCoverageVerification {
46+
violationRules {
47+
rule {
48+
limit {
49+
minimum = 0.80
50+
}
51+
}
52+
}
53+
}
4154
bootJar {
4255
enabled = false
4356
}
44-
}
57+
}

compose.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
services:
2+
database:
3+
image: 'postgres:16.2'
4+
ports:
5+
- '15432:5432'
6+
environment:
7+
- 'POSTGRES_USER=root'
8+
- 'POSTGRES_DB=mydatabase'
9+
- 'POSTGRES_PASSWORD=password'
10+
volumes:
11+
- mydb:/var/lib/postgresql/data
12+
- ./dev/create_keycloak_db.sh:/docker-entrypoint-initdb.d/create_second_db.sh
13+
14+
keycloak:
15+
healthcheck:
16+
test: ["CMD", "curl", "-f", "http://http://0.0.0.0:28080/auth/"]
17+
interval: 5s
18+
timeout: 2s
19+
retries: 15
20+
pid: "host"
21+
deploy:
22+
resources:
23+
limits:
24+
cpus: "0.50"
25+
memory: "512M"
26+
reservations:
27+
cpus: "0.25"
28+
memory: "128M"
29+
depends_on:
30+
- database
31+
volumes:
32+
- keycloak-data:/opt/keycloak/data/
33+
- ./dev/SWD_local_realm.json:/opt/keycloak/data/import/miw_test_realm_local.json
34+
environment:
35+
KEYCLOAK_ADMIN: admin
36+
KEYCLOAK_ADMIN_PASSWORD: admin
37+
DB_VENDOR: postgres
38+
DB_ADDR: database
39+
DB_DATABASE: auth
40+
DB_USER: root
41+
DB_PASSWORD: password
42+
image: quay.io/keycloak/keycloak:24.0.2
43+
entrypoint: ["/opt/keycloak/bin/kc.sh", "start-dev", "--import-realm"]
44+
ports:
45+
- "28080:8080"
46+
47+
volumes:
48+
mydb:
49+
keycloak-data:

0 commit comments

Comments
 (0)