-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Containerising App and verify Mongo and Kafka connections #16
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
version: '2' | ||
version: '3.8' # Specify the version of the Compose file | ||
|
||
networks: | ||
app-network: # Define the network here | ||
driver: bridge | ||
|
||
services: | ||
app: | ||
build: | ||
context: . # Build from the current directory, where Dockerfile is located | ||
dockerfile: Dockerfile # Specify the Dockerfile | ||
container_name: kafka-study-app | ||
|
||
ports: | ||
- "8080:8080" # Expose the app on localhost:8080 | ||
depends_on: | ||
- kafka | ||
- mongodb | ||
command: ["java", "-jar", "/app/app.jar"] # Command to run the app | ||
networks: | ||
- app-network | ||
|
||
zookeeper: | ||
image: wurstmeister/zookeeper:latest | ||
ports: | ||
- "2181:2181" | ||
container_name: zookeeper | ||
networks: | ||
- app-network | ||
|
||
kafka: | ||
image: wurstmeister/kafka:latest | ||
ports: | ||
|
@@ -24,17 +46,23 @@ services: | |
- zookeeper | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
networks: | ||
- app-network | ||
|
||
mongodb: | ||
image: mongo:latest | ||
container_name: mongodb-container | ||
container_name: mongodb | ||
ports: | ||
- "27017:27017" | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: root | ||
MONGO_INITDB_ROOT_PASSWORD: example | ||
volumes: | ||
- mongo-data:/data/db | ||
#sonar - code quality | ||
networks: | ||
- app-network | ||
|
||
# SonarQube for code quality | ||
sonarqube: | ||
image: sonarqube | ||
ports: | ||
|
@@ -47,7 +75,10 @@ services: | |
- sonarqube_data:/opt/sonarqube/data | ||
- sonarqube_logs:/opt/sonarqube/logs | ||
- sonarqube_extensions:/opt/sonarqube/extensions | ||
#Sonar-related postgres | ||
networks: | ||
- app-network | ||
|
||
# SonarQube-related PostgreSQL database | ||
postgres: | ||
image: postgres | ||
environment: | ||
|
@@ -56,6 +87,8 @@ services: | |
POSTGRES_PASSWORD: sonar | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
networks: | ||
- app-network | ||
|
||
prometheus: | ||
image: prom/prometheus:latest | ||
|
@@ -65,6 +98,8 @@ services: | |
- prometheus_data:/prometheus | ||
ports: | ||
- "9090:9090" | ||
networks: | ||
- app-network | ||
|
||
grafana: | ||
image: grafana/grafana:latest | ||
|
@@ -75,6 +110,9 @@ services: | |
- GF_SECURITY_ADMIN_PASSWORD=admin | ||
volumes: | ||
- grafana-storage:/var/lib/grafana | ||
networks: | ||
- app-network | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
volumes: | ||
mongo-data: | ||
sonarqube_data: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ spring.application.name=KafkaStudy | |
kafka.regular.topic=my-topic | ||
regular.kafka.autostart=false | ||
reactive.kafka.autostart=true | ||
spring.kafka.consumer.bootstrap-servers=127.0.0.1:9092 | ||
spring.kafka.consumer.bootstrap-servers=kafka:9092 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
spring.kafka.consumer.group-id=demo-3 | ||
spring.kafka.consumer.auto-offset-reset=earliest | ||
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer | ||
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer | ||
spring.kafka.consumer.properties.session.timeout.ms=30000 | ||
spring.kafka.consumer.properties.heartbeat.interval.ms=10000 | ||
spring.data.mongodb.uri=mongodb://root:example@localhost:27017/testMongoDb?authSource=admin | ||
spring.data.mongodb.uri=mongodb://root:example@mongodb:27017/testMongoDb?authSource=admin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
mask.headers.list=pwd,pass | ||
management.endpoints.web.exposure.include = * |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INSIDE Listener:
Purpose: This is used for communication between Kafka brokers and clients (like producers and consumers) that are within the Docker network. It is typically configured to listen on a specific internal IP address or hostname.
Example Usage: If you have other services running in the same Docker network (e.g., your Spring Boot application), they will connect to Kafka using the INSIDE listener.
OUTSIDE Listener:
Purpose: This listener is exposed to the outside world, allowing clients outside of the Docker network (such as applications running on your local machine) to connect to Kafka. This typically listens on localhost or a specific external IP address.
Example Usage: If you are testing Kafka from your local machine or another service outside the Docker network, you will connect using the OUTSIDE listener.