Skip to content

Commit

Permalink
feat: add mongodb support
Browse files Browse the repository at this point in the history
  • Loading branch information
dilipdhankecha2530 committed Nov 18, 2024
1 parent 991ff74 commit 0448fb8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions chat-dao/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
api project(":chat-api")
}

Expand Down
37 changes: 25 additions & 12 deletions chat-web/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
app:
name: Multi-module Demo
description: Seed multi-module project
name: EDC-Chat-App
description: EDC based chat application
version: 1
port: ${APP_PORT:8080}
security:
enabled: ${SECURITY_ENABLE:true}
realm: ${KEYCLOAK_REALM_NAME:SWD}
realm: ${KEYCLOAK_REALM_NAME:edc-chat}
clientId: ${KEYCLOAK_CLIENT_ID:pb_backend}
roleClientId: ${KEYCLOAK_ROLE_CLIENT_ID:pv_backend}
auth-server-url: ${KEYCLOAK_AUTH_URL:http://localhost:28080}
Expand All @@ -14,12 +14,20 @@ app:
refresh-token-url: ${KEYCLOAK_TOKEN_URL}
corsOrigins: "*"
database:
host: ${DB_HOST:localhost}
port: ${DB_PORT:15432}
name: ${DB_NAME:multi-module-demo}
username: ${DB_USER:root}
password: ${DB_PASSWORD:root}
useSSL: ${USE_SSL:false}
postgres:
host: ${DB_HOST:localhost}
port: ${DB_PORT:15432}
name: ${DB_NAME:chat}
username: ${DB_USER:root}
password: ${DB_PASSWORD:root}
useSSL: ${USE_SSL:false}
mongodb:
host: ${MONGO_HOST:localhost}
port: ${MONGO_PORT:27017}
database: ${MONGO_DB_NAME:chat}
username: ${MONGO_USER:root}
password: ${MONGO_PASSWORD:root}
authMechanism: SCRAM-SHA-1
swagger:
clientId: ${KEYCLOAK_CLIENT_ID:swd_public_client}
multipart:
Expand Down Expand Up @@ -59,6 +67,8 @@ management:
health:
db:
enabled: true
mongo:
enabled: true
diskspace:
enabled: false
livenessstate:
Expand Down Expand Up @@ -94,10 +104,13 @@ spring:
database-platform: org.hibernate.dialect.PostgreSQLDialect
show-sql: false
datasource:
url: jdbc:postgresql://${app.database.host}:${app.database.port}/${app.database.name}?useSSL=${app.database.useSSL}
username: ${app.database.username}
password: ${app.database.password}
url: jdbc:postgresql://${app.database.postgres.host}:${app.database.postgres.port}/${app.database.postgres.name}?useSSL=${app.database.postgres.useSSL}
username: ${app.database.postgres.username}
password: ${app.database.postgres.password}
driverClassName: org.postgresql.Driver
data:
mongodb:
uri: mongodb://${app.database.mongodb.username}:${app.database.mongodb.password}@${app.database.mongodb.host}:${app.database.mongodb.port}/${app.database.mongodb.database}?authSource=admin&authMechanism=${app.database.mongodb.authMechanism}
security:
oauth2:
resourceserver:
Expand Down
11 changes: 11 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ services:
volumes:
- mydb:/var/lib/postgresql/data
- ./dev/create_keycloak_db.sh:/docker-entrypoint-initdb.d/create_second_db.sh
mongodb:
image: 'mongo:latest'
environment:
- 'MONGO_INITDB_DATABASE=mydatabase'
- 'MONGO_INITDB_ROOT_PASSWORD=secret'
- 'MONGO_INITDB_ROOT_USERNAME=root'
ports:
- '27017:27017'
volumes:
- mongodb:/data/db

keycloak:
healthcheck:
Expand Down Expand Up @@ -38,4 +48,5 @@ services:

volumes:
mydb:
mongodb:
keycloak-data:

0 comments on commit 0448fb8

Please sign in to comment.