spring cloud

This commit is contained in:
petrelevich
2025-06-25 07:33:21 +03:00
parent 31da32caec
commit 1a7aada572
7 changed files with 145 additions and 54 deletions
@@ -1,3 +1,7 @@
plugins {
id("com.google.cloud.tools.jib")
}
dependencies {
implementation(project(":kafka-log-appender"))
implementation("net.logstash.logback:logstash-logback-encoder")
@@ -13,3 +17,24 @@ dependencies {
implementation("io.micrometer:micrometer-tracing-bridge-otel") // bridges the Micrometer Observation API to OpenTelemetry.
implementation("io.opentelemetry:opentelemetry-exporter-zipkin") // reports traces to Zipkin.
}
jib {
container {
creationTime.set("USE_CURRENT_TIMESTAMP")
}
from {
image = "bellsoft/liberica-openjdk-alpine-musl:21.0.1"
}
to {
image = "localrun/api-gateway"
tags = setOf(project.version.toString())
}
}
tasks {
build {
dependsOn(spotlessApply)
dependsOn(jibBuildTar)
}
}
@@ -0,0 +1,16 @@
#!/bin/bash
../gradlew :api-gateway:build
docker load --input build/jib-image.tar
docker stop api-gateway
docker run --rm -d --name api-gateway \
--memory=512m \
--cpus 1 \
--network="host" \
-v $HOME/.ssh:/root/.ssh \
-e JAVA_TOOL_OPTIONS="-XX:InitialRAMPercentage=80 -XX:MaxRAMPercentage=80" \
localrun/api-gateway:latest
@@ -7,7 +7,7 @@ docker load --input build/jib-image.tar
docker stop config-server
docker run --rm -d --name config-server \
--memory=256m \
--memory=1024m \
--cpus 1 \
--network="host" \
-v $HOME/.ssh:/root/.ssh \
@@ -1,52 +1,14 @@
services:
opensearch-node1:
image: opensearchproject/opensearch:2.18.0
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node1 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1 # Nodes eligibile to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
ports:
- 9200:9200 # REST API
- 9600:9600 # Performance Analyzer
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:2.18.0
container_name: opensearch-dashboards
ports:
- 5601:5601 # Map host port 5601 to container port 5601
expose:
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
environment:
- 'OPENSEARCH_HOSTS=["http://opensearch-node1:9200","http://opensearch-node2:9200"]'
- "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
networks:
- opensearch-net
#logstash
logstash:
image: opensearchproject/logstash-oss-with-opensearch-output-plugin:7.16.2
container_name: logstash
volumes:
- ./logstash.conf:/usr/share/logstash/pipeline/logstash.conf
networks:
- opensearch-net
deploy:
resources:
limits:
memory: "512M"
zookeeper:
image: confluentinc/cp-zookeeper:6.2.0
@@ -54,8 +16,10 @@ services:
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- opensearch-net
deploy:
resources:
limits:
memory: "256M"
broker:
image: confluentinc/cp-kafka:7.0.0
@@ -72,8 +36,10 @@ services:
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
networks:
- opensearch-net
deploy:
resources:
limits:
memory: "512M"
kafka-ui:
container_name: kafka-ui
@@ -83,6 +49,10 @@ services:
DYNAMIC_CONFIG_ENABLED: 'true'
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: localhost:9092
deploy:
resources:
limits:
memory: "256M"
zipkin:
container_name: zipkin
@@ -90,9 +60,3 @@ services:
network_mode: "host"
expose:
- "9411"
volumes:
opensearch-data1:
networks:
opensearch-net:
@@ -0,0 +1,70 @@
services:
opensearch-node1:
image: opensearchproject/opensearch:2.18.0
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node1 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
ports:
- 9200:9200 # REST API
- 9600:9600 # Performance Analyzer
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
opensearch-node2:
image: opensearchproject/opensearch:2.18.0
container_name: opensearch-node2
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node2 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
- "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data # Creates volume called opensearch-data2 and mounts it to the container
networks:
- opensearch-net # All of the containers will join the same Docker bridge network
opensearch-dashboards:
image: opensearchproject/opensearch-dashboards:2.18.0
container_name: opensearch-dashboards
ports:
- 5601:5601 # Map host port 5601 to container port 5601
expose:
- "5601" # Expose port 5601 for web access to OpenSearch Dashboards
environment:
- 'OPENSEARCH_HOSTS=["http://opensearch-node1:9200","http://opensearch-node2:9200"]'
- "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
networks:
- opensearch-net
volumes:
opensearch-data1:
opensearch-data2:
networks:
opensearch-net:
@@ -14,7 +14,7 @@ input {
output {
opensearch {
hosts => "http://opensearch-node1:9200"
hosts => "http://178.130.58.173:9200"
user => "admin"
password => "admin"
index => "logstash-logs-%{+YYYY.MM.dd}"
@@ -0,0 +1,16 @@
#!/bin/bash
../gradlew :eureka-server:build
docker load --input build/jib-image.tar
docker stop eureka-server
docker run --rm -d --name eureka-server \
--memory=512m \
--cpus 1 \
--network="host" \
-v $HOME/.ssh:/root/.ssh \
-e JAVA_TOOL_OPTIONS="-XX:InitialRAMPercentage=80 -XX:MaxRAMPercentage=80" \
localrun/eureka-server:latest