Skip to content

Commit

Permalink
Added MongoDB connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugi-Games committed May 19, 2024
1 parent 2bdabba commit 95e4d09
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- "8081:8080"
depends_on:
- postgres
- mongodb
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/test
SPRING_DATASOURCE_USERNAME: postgres
Expand All @@ -25,3 +26,39 @@ services:
- "5432:5432"
volumes:
- ./data:/var/lib/postgresql/data

mongodb:
image: mongo:latest
container_name: mongodb
restart: always
ports:
- "27017:27017"
networks:
- mongo-net
volumes:
- data:/data
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 1234

mongo-express:
image: mongo-express
container_name: mongo-express
restart: always
ports:
- "8082:8081"
networks:
- mongo-net
depends_on:
- mongodb
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: 1234
ME_CONFIG_MONGODB_SERVER: mongodb

volumes:
data: {}

networks:
mongo-net:
driver: bridge
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ spring:
#show-sql: true
properties:
hibernate:
format_sql: true
format_sql: true
data:
mongodb:
authentication-database: admin
username: root
password: 1234
database: test
port: 27017
host: localhost

0 comments on commit 95e4d09

Please sign in to comment.