feat(deploy): add internal Kafka KRaft broker and Go broker settings

This commit is contained in:
shira committed 2026-10-05 22:28:30 +03:00
1 parent 565ca94bbb
commit 197661145e
16 files changed
+289 -17

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ config: ## Render all Compose files with safe example values
build: ## Build local frontend and backend images
APP_PROJECT="$(APP_PROJECT)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" build
up: ## Start the core app, PostgreSQL, Redis, and SeaweedFS without monitoring
up: ## Start the core app, PostgreSQL, Redis, SeaweedFS, and Kafka without monitoring
@test -f "$(ENV_FILE)" || { printf 'Missing %s. Copy .env.example to .env and replace the placeholder passwords.\n' "$(ENV_FILE)" >&2; exit 2; }
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" up -d
+1 -1
View File
@@ -4,7 +4,7 @@
Configuration for running the application with Docker Compose and Nginx.
- `docker/docker-compose.yml` starts the core stack with PostgreSQL, Redis, and SeaweedFS.
- `docker/docker-compose.yml` starts the core stack with PostgreSQL, Redis, SeaweedFS, and Kafka.
- `docker/docker-compose.ml.yml` and `docker/docker-compose.monitoring.yml` run ML and monitoring as separate projects.
- `nginx/` configures frontend serving and API proxying.
- `scripts/` contains the isolated stack smoke check.
+1 -1
View File
@@ -4,7 +4,7 @@
Конфигурация запуска через Docker Compose и Nginx.
- `docker/docker-compose.yml` поднимает основной стек с PostgreSQL, Redis и SeaweedFS.
- `docker/docker-compose.yml` поднимает основной стек с PostgreSQL, Redis, SeaweedFS и Kafka.
- `docker/docker-compose.ml.yml` и `docker/docker-compose.monitoring.yml` запускают ML и мониторинг отдельными проектами.
- `nginx/` содержит конфигурацию раздачи frontend и проксирования API.
- `scripts/` содержит smoke-проверку изолированного стека.
+70
View File
@@ -103,6 +103,73 @@ services:
cpus: "1.0"
memory: 1G
kafka:
image: apache/kafka:latest
environment:
# Setting any KAFKA_* property disables the image's default
# server.properties, so every required broker setting is listed here.
CLUSTER_ID: ${KAFKA_CLUSTER_ID:?Set KAFKA_CLUSTER_ID in the root .env file}
KAFKA_NODE_ID: "1"
KAFKA_PROCESS_ROLES: broker,controller
# The controller listener stays on container loopback; only the
# client listener is reachable on the Compose network.
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://127.0.0.1:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093
KAFKA_LOG_DIRS: /var/lib/kafka/data
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
KAFKA_NUM_PARTITIONS: "1"
KAFKA_DEFAULT_REPLICATION_FACTOR: "1"
KAFKA_MIN_INSYNC_REPLICAS: "1"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: "1"
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1"
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_SHARE_COORDINATOR_STATE_TOPIC_MIN_ISR: "1"
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0"
KAFKA_LOG_RETENTION_HOURS: "168"
KAFKA_LOG_RETENTION_BYTES: "1073741824"
KAFKA_LOG_SEGMENT_BYTES: "134217728"
KAFKA_HEAP_OPTS: -Xms256m -Xmx512m
# An empty value lets the image enable an unauthenticated JMX agent with
# an RMI port on all container interfaces. This non-empty value opens no
# JMX port; metrics export is not configured yet.
KAFKA_JMX_OPTS: -Djava.rmi.server.hostname=127.0.0.1
volumes:
- kafka_data:/var/lib/kafka/data
# The image declares these paths as volumes for TLS material and config
# overrides. Neither is used here; tmpfs avoids an anonymous volume per
# container recreation.
tmpfs:
- /etc/kafka/secrets:size=1m,mode=0755
- /mnt/shared/config:size=1m,mode=0755
expose:
- "9092"
healthcheck:
# CLI tools inherit KAFKA_HEAP_OPTS, so the probe gets its own small heap
# to stay inside the container memory limit next to the broker.
test: ["CMD-SHELL", "KAFKA_HEAP_OPTS='-Xms32m -Xmx64m' /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092 >/dev/null 2>&1"]
interval: 15s
timeout: 10s
retries: 10
start_period: 30s
# Allow a controlled shutdown so the next start skips log recovery.
stop_grace_period: 30s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
backend:
build:
context: ../../backend
@@ -119,6 +186,7 @@ services:
SEAWEEDFS_BUCKET: ${SEAWEEDFS_BUCKET:?Set SEAWEEDFS_BUCKET in the root .env file}
SEAWEEDFS_REGION: us-east-1
SEAWEEDFS_TIMEOUT: 10s
KAFKA_BROKERS: kafka:9092
depends_on:
postgres:
condition: service_healthy
@@ -173,6 +241,8 @@ volumes:
name: ${APP_PROJECT:-app}_postgres_data
seaweedfs_data:
name: ${APP_PROJECT:-app}_seaweedfs_data
kafka_data:
name: ${APP_PROJECT:-app}_kafka_data
networks:
default:
+1 -1
View File
@@ -18,7 +18,7 @@ compose() {
"$@"
}
for volume in "${project}_postgres_data" "${project}_seaweedfs_data"; do
for volume in "${project}_postgres_data" "${project}_seaweedfs_data" "${project}_kafka_data"; do
if docker volume inspect "$volume" >/dev/null 2>&1; then
printf 'Refusing to use existing smoke volume %s.\n' "$volume" >&2
exit 2