Change in docker compose to deploy all containers

This commit is contained in:
Diego Rubio
2020-11-26 19:18:08 +01:00
parent 416f0aea7f
commit e1c892baa3
4 changed files with 35 additions and 31 deletions

View File

@@ -1,19 +0,0 @@
package es.dbiosag.command.infrasturcture.configuration;
import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;
@Configuration
public class KafkaTopicConfig {
@Value(value = "${message.topic.createPhone}")
private String topicName;
@Bean
public NewTopic topicProducePhone() {
return TopicBuilder.name(topicName).build();
}
}

View File

@@ -13,8 +13,9 @@ spring:
enabled: true enabled: true
kafka: kafka:
bootstrap-servers: localhost:9092 bootstrap-servers: kafka1:9092
consumer.group-id: phone-producers consumer:
group-id: test-consumer-group
message: message:
topic: topic:
createPhone: create-phone createPhone: create-phone

View File

@@ -1,5 +1,5 @@
server: server:
port: 8083 port: 8082
spring: spring:
datasource: datasource:
driverClassName: org.h2.Driver driverClassName: org.h2.Driver
@@ -13,8 +13,9 @@ spring:
enabled: true enabled: true
kafka: kafka:
bootstrap-servers: localhost:9092 bootstrap-servers: kafka1:9092
consumer.group-id: phone-producers consumer:
group-id: test-consumer-group
message: message:
topic: topic:
createPhone: create-phone createPhone: create-phone

View File

@@ -1,11 +1,16 @@
version: '2.1' version: '2.1'
networks:
test:
services: services:
zoo1: zoo1:
image: zookeeper:3.4.9 image: zookeeper:3.4.9
hostname: zoo1 hostname: zoo1
ports: ports:
- "2181:2181" - "2181:2181"
networks:
- test
environment: environment:
ZOO_MY_ID: 1 ZOO_MY_ID: 1
ZOO_PORT: 2181 ZOO_PORT: 2181
@@ -22,6 +27,7 @@ services:
environment: environment:
KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka1:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092 KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka1:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
KAFKA_CREATE_TOPICS: create-phone:2:1
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181" KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_BROKER_ID: 1 KAFKA_BROKER_ID: 1
@@ -31,6 +37,13 @@ services:
- ./zk-single-kafka-single/kafka1/data:/var/lib/kafka/data - ./zk-single-kafka-single/kafka1/data:/var/lib/kafka/data
depends_on: depends_on:
- zoo1 - zoo1
networks:
- test
healthcheck:
test: [ "CMD", "nc", "-vz", "localhost", "9092" ]
interval: 30s
timeout: 10s
retries: 3
demo-command: demo-command:
build: build:
@@ -41,27 +54,35 @@ services:
ports: ports:
- "8081:8081" - "8081:8081"
depends_on: depends_on:
- zoo1 kafka1:
- kafka1 condition: service_healthy
networks:
- test
demo-query-1: demo-query-1:
build: build:
context: demo-query context: demo-query
dockerfile: Dockerfile dockerfile: Dockerfile
image: demo-query image: demo-query
hostname: demo-query-1
ports: ports:
- "8082:8082" - "8082:8082"
depends_on: depends_on:
- zoo1 kafka1:
- kafka1 condition: service_healthy
networks:
- test
demo-query-2: demo-query-2:
build: build:
context: demo-query context: demo-query
dockerfile: Dockerfile dockerfile: Dockerfile
image: demo-query image: demo-query
hostname: demo-query-2
ports: ports:
- "8082:8083" - "8083:8082"
depends_on: depends_on:
- zoo1 kafka1:
- kafka1 condition: service_healthy
networks:
- test