diff --git a/docker/.env.example b/docker/.env.example index e14d824..c739b09 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,6 +1,10 @@ USERNAME=23f03013e37f -PORT=8080 -UI_VERSION=1.0 -POST_VERSION=1.0 -COMMENT_VERSION=1.0 +PORT=9292 +UI_VERSION=latest +POST_VERSION=logging +COMMENT_VERSION=logging DB_VERSION=4.4.24 +PROMETHEUS_VERSION=2.1.0 +FLUENT_VERSION=logging +COMPOSE_PROJECT_NAME=logging +ZIPKIN_ENABLED=true diff --git a/docker/.gitignore b/docker/.gitignore index 76a6230..d6450c5 100644 --- a/docker/.gitignore +++ b/docker/.gitignore @@ -1,3 +1,4 @@ +.secrets/* **/.env build_info.txt *.pyc diff --git a/docker/docker-compose-apps.yml b/docker/docker-compose-apps.yml new file mode 100644 index 0000000..359ea93 --- /dev/null +++ b/docker/docker-compose-apps.yml @@ -0,0 +1,101 @@ +version: '3.3' +name: logging +services: + post_db: + image: mongo:${DB_VERSION} + volumes: + - post_db:/data/db + networks: + - back_net + ui: + image: ${USERNAME}/ui:${UI_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} + ports: + - ${PORT}:9292/tcp + networks: + - front_net + depends_on: + - fluent-bit + - post_db + - post + - comment + command: puma --debug -w 2 + logging: + driver: "fluentd" + options: + fluentd-address: localhost:24224 + tag: service.ui + post: + image: ${USERNAME}/post:${POST_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} + - COMPOSE_PROJECT_NAME + networks: + - back_net + - front_net + logging: + driver: "fluentd" + options: + fluentd-address: localhost:24224 + tag: service.post + depends_on: + - fluent-bit + comment: + image: ${USERNAME}/comment:${COMMENT_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} + logging: + driver: "fluentd" + options: + fluentd-address: localhost:24224 + tag: service.post + networks: + - back_net + - front_net + depends_on: + - fluent-bit + zipkin: + image: openzipkin/zipkin:2.21.0 + ports: + - "9411:9411" + networks: + - back_net + - front_net + fluent-bit: + image: ${USERNAME}/fluent-bit:${FLUENT_VERSION} + ports: + - "24224:24224" + - "24224:24224/udp" + depends_on: + - elasticsearch + networks: + - back_net + elasticsearch: + image: elasticsearch:7.17.3 + environment: + - discovery.type=single-node + expose: + - "9200" + ports: + - "9200:9200" + networks: + - back_net + kibana: + image: kibana:7.17.3 + ports: + - "5601:5601" + networks: + - front_net +volumes: + post_db: + prometheus_data: +networks: + front_net: + ipam: + config: + - subnet: 10.0.1.0/24 + back_net: + ipam: + config: + - subnet: 10.0.2.0/24 diff --git a/docker/docker-compose-logging.yml b/docker/docker-compose-logging.yml new file mode 100644 index 0000000..0b0ea17 --- /dev/null +++ b/docker/docker-compose-logging.yml @@ -0,0 +1,25 @@ +version: '3' +services: + zipkin: + image: openzipkin/zipkin:2.21.0 + ports: + - "9411:9411" + fluent-bit: + image: ${USERNAME}/fluent-bit:${FLUENT_VERSION} + ports: + - "24224:24224" + - "24224:24224/udp" + depends_on: + - elasticsearch + elasticsearch: + image: elasticsearch:7.17.3 + environment: + - discovery.type=single-node + expose: + - "9200" + ports: + - "9200:9200" + kibana: + image: kibana:7.17.3 + ports: + - "5601:5601" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0f4ff01..927963c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,5 @@ version: '3.3' +name: logging services: post_db: image: mongo:${DB_VERSION} @@ -8,6 +9,8 @@ services: - back_net ui: image: ${USERNAME}/ui:${UI_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} ports: - ${PORT}:9292/tcp networks: @@ -17,13 +20,28 @@ services: - post - comment command: puma --debug -w 2 + logging: + driver: "fluentd" + options: + fluentd-address: localhost:24224 + tag: service.ui post: image: ${USERNAME}/post:${POST_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} + - COMPOSE_PROJECT_NAME networks: - back_net - front_net + logging: + driver: "fluentd" + options: + fluentd-address: localhost:24224 + tag: service.post comment: image: ${USERNAME}/comment:${COMMENT_VERSION} + environment: + - ZIPKIN_ENABLED=${ZIPKIN_ENABLED} networks: - back_net - front_net @@ -73,11 +91,9 @@ services: networks: - back_net - front_net - volumes: post_db: prometheus_data: - networks: front_net: ipam: