Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ out/

### VS Code ###
.vscode/
/logs/**
/.github/git-commit-instructions.md
/monitoring/grafana/volume/**
18 changes: 15 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,26 @@ dependencies {

// Apache Commons Lang3
implementation 'org.apache.commons:commons-lang3:3.12.0'

// WebClient
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'

// monoitoring
implementation("org.springframework.boot:spring-boot-starter-actuator")
runtimeOnly("io.micrometer:micrometer-registry-prometheus")

// logging
implementation 'net.logstash.logback:logstash-logback-encoder:8.1'
}

tasks.named('test') {
useJUnitPlatform()
}


tasks.withType(Checkstyle){
tasks.withType(Checkstyle) {
reports {
xml.required = true
html.required = true
Expand All @@ -86,7 +98,7 @@ tasks.withType(Checkstyle){

checkstyle {
configFile = file("checkstyle/config/rules.xml")
configProperties = ["suppressionFile" : "checkstyle/config/suppressions.xml"]
configProperties = ["suppressionFile": "checkstyle/config/suppressions.xml"]
maxWarnings = 0
}

Expand Down
11 changes: 1 addition & 10 deletions checkstyle/config/rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ The following rules in the Naver coding convention cannot be checked by this con
<module name="TreeWalker">
<!-- Start of Naming chapter -->

<!-- [list-uppercase-abbr] -->
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
<message key="abbreviation.as.word"
value="[list-uppercase-abbr] Abbreviation in name ''{0}'' must contain no more than {1}"/>
<property name="allowedAbbreviations" value="DAO,BO,MySQL,SQL"/>
</module>

<!-- [package-lowercase] -->
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
Expand Down Expand Up @@ -97,7 +88,7 @@ The following rules in the Naver coding convention cannot be checked by this con
<!-- [var-lower-camelcase], [avoid-1-char-var] -->
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][a-zA-Z0-9][a-zA-Z0-9]*$"/>
<property name="format" value="^[a-zA-Z]$|^[a-z][a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="[var-lower-camelcase][avoid-1-char-var] Local variable name ''{0}'' must match pattern ''{1}''."/>
Expand Down
68 changes: 68 additions & 0 deletions docker-compose-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '3.8'
services:
redis:
image: redis:alpine
container_name: rabbit-redis
hostname: redis
ports:
- "6379:6379"
networks:
- rabbit-db

mysql_master:
container_name: rabbit-mysql-master
image: mysql:8.0
environment:
MYSQL_DATABASE: rabbit
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: 1234
ports:
- "3306:3306"
volumes:
- ./mysql/master-data-source.cnf:/etc/mysql/conf.d/my.cnf
- ./mysql/init-master.sql:/docker-entrypoint-initdb.d/01-init-master.sql
networks:
- rabbit-db
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p1234" ]
timeout: 20s
retries: 10

mysql_replica:
container_name: rabbit-mysql-replica
image: mysql:8.0
environment:
MYSQL_DATABASE: rabbit
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: 1234
ports:
- "3307:3306"
volumes:
- ./mysql/replica-data-source.cnf:/etc/mysql/conf.d/my.cnf
networks:
- rabbit-db
depends_on:
mysql_master:
condition: service_healthy
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p1234" ]
timeout: 20s
retries: 10

mysql_replication_setup:
image: mysql:8.0
container_name: mysql_replication_setup
volumes:
- ./mysql/setup-replication.sh:/setup-replication.sh
command: [ "/bin/bash", "/setup-replication.sh" ]
networks:
- rabbit-db
depends_on:
mysql_master:
condition: service_healthy
mysql_replica:
condition: service_healthy
restart: "no"

networks:
rabbit-db:
94 changes: 94 additions & 0 deletions docker-compose-elk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: "3.8"

services:
setup:
profiles: [ setup ]
init: true
build:
context: elk/setup/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION:-8.10.2}
volumes:
- ./elk/setup/sh/entrypoint.sh:/entrypoint.sh:ro,Z
- ./elk/setup/sh/lib.sh:/lib.sh:ro,Z
- ./elk/setup/roles:/roles:ro,Z
environment:
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-rabbit1234}
KIBANA_SYSTEM_PASSWORD: ${KIBANA_SYSTEM_PASSWORD:-rabbit1234}
LOGSTASH_USERNAME: ${LOGSTASH_USERNAME:-rabbit_logstash}
LOGSTASH_PASSWORD: ${LOGSTASH_PASSWORD:-rabbit1234}
networks: [ rabbit-elk ]
depends_on: [ elasticsearch ]

elasticsearch:
container_name: rabbit-elasticsearch
build:
context: ./elk/elasticsearch
args:
ELASTIC_VERSION: ${ELASTIC_VERSION:-8.10.2}
volumes:
- ./elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro,Z
- elasticsearch:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_PASSWORD: ${ELASTIC_PASSWORD:-rabbit1234}
discovery.type: single-node
networks: [ rabbit-elk ]

logstash:
container_name: rabbit-logstash
build:
context: ./elk/logstash/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION:-8.10.2}
volumes:
- ./elk/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro,Z
- ./elk/logstash/pipeline:/usr/share/logstash/pipeline:ro,Z
ports:
- "5044:5044"
- "50000:50000/tcp"
- "50000:50000/udp"
- "9600:9600"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
LOGSTASH_USERNAME: ${LOGSTASH_USERNAME:-rabbit_logstash}
LOGSTASH_PASSWORD: ${LOGSTASH_PASSWORD:-rabbit1234}
networks: [ rabbit-elk ]
depends_on: [ elasticsearch ]

kibana:
container_name: rabbit-kibana
build:
context: ./elk/kibana/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION:-8.10.2}
volumes:
- ./elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml:ro,Z
ports:
- "5601:5601"
environment:
KIBANA_SYSTEM_PASSWORD: ${KIBANA_SYSTEM_PASSWORD:-rabbit1234}
networks: [ rabbit-elk ]
depends_on: [ elasticsearch ]

filebeat:
container_name: rabbit-filebeat
user: root
build:
context: ./elk/filebeat/
args:
ELASTIC_VERSION: ${ELASTIC_VERSION:-8.10.2}
volumes:
- ./logs:/logs
- ./elk/filebeat/config/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro,Z
networks: [ rabbit-elk ]
depends_on: [ logstash ]

volumes:
elasticsearch:

networks:
rabbit-elk:
33 changes: 33 additions & 0 deletions docker-compose-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.8'
services:
prometheus:
build: ./monitoring/prometheus
container_name: rabbit-prometheus
ports:
- 9090:9090
environment:
ACTUATOR_METRICS_PATH: ${ACTUATOR_METRICS_PATH:-/actuator/prometheus}
ACTUATOR_USERNAME: ${ACTUATOR_USERNAME:-rabbit}
ACTUATOR_PASSWORD: ${ACTUATOR_PASSWORD:-rabbit1234}
restart: always
networks:
- rabbit-monitoring

grafana:
image: grafana/grafana
container_name: rabbit-grafana
ports:
- 3000:3000
volumes:
- ./monitoring/grafana/volume:/var/lib/grafana
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-rabbit}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:-rabbit1234}
restart: always
networks:
- rabbit-monitoring
depends_on:
- prometheus

networks:
rabbit-monitoring:
40 changes: 5 additions & 35 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'
services:
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
container_name: rabbit-rabbitmq
ports:
- "5672:5672"
- "15672:15672"
Expand All @@ -12,50 +12,20 @@ services:
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest

mongodb:
image: mongo:latest
container_name: mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 1234
MONGO_INITDB_DATABASE: rabbitmq
ports:
- "27017:27017"
networks:
- my_network

redis:
image: redis:alpine
container_name: redis
hostname: redis
ports:
- "6379:6379"
networks:
- my_network

mysql:
image: mysql:8.0
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: rabbitmq
ports:
- "3306:3306"
networks:
- my_network
- rabbit-default

nginx:
image: nginx:latest
container_name: nginx
container_name: rabbit-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/config/nginx.conf:/etc/nginx/conf.d/default.conf
- ./nginx/ssl:/etc/nginx/ssl
networks:
- my_network
- rabbit-default

networks:
my_network:
rabbit-default:
4 changes: 4 additions & 0 deletions elk/elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ARG ELASTIC_VERSION

# https://www.docker.elastic.co/
FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION}
12 changes: 12 additions & 0 deletions elk/elasticsearch/config/elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
## Default Elasticsearch configuration from Elasticsearch base image.
## https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/config/elasticsearch.yml
#
cluster.name: docker-cluster
network.host: 0.0.0.0

xpack.license.self_generated.type: trial
xpack.security.enabled: true

# 추후 확장 시 제거
discovery.type: single-node
10 changes: 10 additions & 0 deletions elk/filebeat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG ELASTIC_VERSION

FROM docker.elastic.co/beats/filebeat:${ELASTIC_VERSION}

COPY config/filebeat.yml /usr/share/filebeat/filebeat.yml
#USER root
#
#RUN mkdir /var/logs
#
#RUN chown -R root /usr/share/filebeat
14 changes: 14 additions & 0 deletions elk/filebeat/config/filebeat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
filebeat.inputs:
- type: log
enabled: true
paths:
- /logs/*.log
json.keys_under_root: true
json.add_error_key: true
json.overwrite_keys: true

output.logstash:
hosts: ["logstash:5044"]

setup.kibana:
host: "http://kibana:5601"
7 changes: 7 additions & 0 deletions elk/kibana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARG ELASTIC_VERSION

# https://www.docker.elastic.co/
FROM docker.elastic.co/kibana/kibana:${ELASTIC_VERSION}

# Add your kibana plugins setup here
# Example: RUN kibana-plugin install <name|url>
9 changes: 9 additions & 0 deletions elk/kibana/config/kibana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server.name: kibana
server.host: 0.0.0.0

elasticsearch.hosts: [ "http://elasticsearch:9200" ]
elasticsearch.username: kibana_system
elasticsearch.password: ${KIBANA_SYSTEM_PASSWORD}

monitoring.ui.container.elasticsearch.enabled: true
monitoring.ui.container.logstash.enabled: true
Loading