File size: 2,323 Bytes
5412a90
 
06cfa59
5412a90
 
 
06cfa59
 
 
 
 
 
 
 
 
 
 
5412a90
06cfa59
5412a90
06cfa59
5412a90
 
 
 
 
06cfa59
5412a90
 
 
 
 
 
06cfa59
5412a90
06cfa59
5412a90
06cfa59
5412a90
06cfa59
d8389a8
06cfa59
d8389a8
5412a90
 
 
 
 
 
 
 
 
 
 
d8389a8
5412a90
d8389a8
 
 
 
 
 
5412a90
 
 
d8389a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
services:
  kafka:
    image: apache/kafka:3.9.0
    ports:
      - "9092:9092"
    environment:
      KAFKA_NODE_ID: 1
      KAFKA_PROCESS_ROLES: broker,controller
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
      KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
      KAFKA_NUM_PARTITIONS: 4
      KAFKA_LOG_RETENTION_HOURS: 24
      CLUSTER_ID: "EuNEx-kafka-cluster-001"
    volumes:
      - kafka_data:/tmp/kraft-combined-logs
    healthcheck:
      test: ["CMD-SHELL", "/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 5

  kafka-init:
    image: apache/kafka:3.9.0
    depends_on:
      kafka:
        condition: service_healthy
    entrypoint: ["/bin/bash", "-c"]
    command:
      - |
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists \
          --topic eunex.recovery.fragments --partitions 4 --replication-factor 1
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists \
          --topic eunex.trades --partitions 4 --replication-factor 1
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists \
          --topic eunex.market-data --partitions 4 --replication-factor 1
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists \
          --topic eunex.orders --partitions 4 --replication-factor 1
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists \
          --topic eunex.control --partitions 1 --replication-factor 1
        echo "Topics created."

  eunex:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    depends_on:
      kafka-init:
        condition: service_completed_successfully
    environment:
      EUNEX_KAFKA_BROKERS: kafka:9092
      EUNEX_DATA_DIR: /app/data
    ports:
      - "7860:7860"
      - "8090:8090"
      - "8091:8091"
      - "9001:9001"
    volumes:
      - eunex_data:/app/data

volumes:
  kafka_data:
  eunex_data: