Skip to content

Commit 0f29475

Browse files
Merge pull request #1 from smartSenseSolutions/feat/docker-compose-support
Feat/docker compose support
2 parents 5d4b968 + 100865d commit 0f29475

File tree

21 files changed

+2631
-44
lines changed

21 files changed

+2631
-44
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ subprojects {
3636

3737
tasks.named('test') {
3838
useJUnitPlatform()
39-
}
4039

40+
}
4141
bootJar {
4242
enabled = false
4343
}
44-
}
44+
}

compose.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
depends_on:
22+
- database
23+
volumes:
24+
- keycloak-data:/opt/keycloak/data/
25+
- ./dev/SWD_local_realm.json:/opt/keycloak/data/import/miw_test_realm_local.json
26+
environment:
27+
KEYCLOAK_ADMIN: admin
28+
KEYCLOAK_ADMIN_PASSWORD: admin
29+
DB_VENDOR: postgres
30+
DB_ADDR: database
31+
DB_DATABASE: auth
32+
DB_USER: root
33+
DB_PASSWORD: password
34+
image: quay.io/keycloak/keycloak:24.0.2
35+
entrypoint: ["/opt/keycloak/bin/kc.sh", "start-dev", "--import-realm"]
36+
ports:
37+
- "28080:8080"
38+
39+
volumes:
40+
mydb:
41+
keycloak-data:

0 commit comments

Comments
 (0)