-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
119 lines (109 loc) · 3.74 KB
/
Copy pathdocker-compose.yml
File metadata and controls
119 lines (109 loc) · 3.74 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
services:
postgres:
image: postgres:17-alpine
container_name: jobqueue-postgres
restart: unless-stopped
environment:
POSTGRES_DB: jobqueue
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5434:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U jobqueue -d jobqueue"]
interval: 10s
timeout: 5s
retries: 5
kafka:
image: apache/kafka:4.2.0
container_name: jobqueue-kafka
restart: unless-stopped
ports:
- "9092:9092"
environment:
# === KRaft Mode (no ZooKeeper) ===
# Unique ID for this broker in the cluster
KAFKA_NODE_ID: 1
# This node acts as both broker (stores data) AND controller (manages cluster metadata).
# In multi-node clusters you'd split these roles.
KAFKA_PROCESS_ROLES: broker,controller
# Quorum voters = list of controller nodes with format: nodeId@host:port.
# Single-node: just this node voting for itself on port 9093 (controller port).
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
# === Network Listeners ===
# Listeners bind to ports. Format: LISTENER_NAME://host:port
# - PLAINTEXT on 9092 for client traffic (API, Worker, Kafka UI)
# - CONTROLLER on 9093 for internal Raft quorum communication
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093
# Advertised listeners tell clients HOW to reach Kafka.
# Inside Docker, services use container name "kafka:9092".
# For host access (e.g., running app locally), use "localhost:9092".
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
# Maps listener names to security protocols (PLAINTEXT, SSL, SASL, etc.)
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT
# Which listener the controller uses for inter-controller communication
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
# Which listener the brokers use to talk to each other
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
# === Cluster Identity ===
# A unique base64-encoded cluster ID.
KAFKA_CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk
# === Single-Node Tuning ===
# Default partitions for auto-created topics
KAFKA_NUM_PARTITIONS: 1
# Replication factor for internal topics must be 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
# Auto-create topics when producers or consumers reference them
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
volumes:
- kafka-data:/var/lib/kafka/data
healthcheck:
test: ["CMD-SHELL", "/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list >/dev/null 2>&1"]
interval: 15s
timeout: 10s
retries: 10
kafka-ui:
image: provectuslabs/kafka-ui:v0.7.2
container_name: jobqueue-kafka-ui
restart: unless-stopped
ports:
- "8081:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
depends_on:
kafka:
condition: service_healthy
api-service:
build:
context: .
dockerfile: api/Dockerfile
container_name: jobqueue-api
ports:
- "8080:8080"
env_file:
- api/.env
depends_on:
postgres:
condition: service_healthy
kafka:
condition: service_healthy
worker-service:
build:
context: .
dockerfile: worker/Dockerfile
container_name: jobqueue-worker
env_file:
- worker/.env
depends_on:
postgres:
condition: service_healthy
kafka:
condition: service_healthy
volumes:
postgres-data:
kafka-data: