Files
todo-vibe-coding/docker-compose.yml
2026-03-11 23:58:23 +08:00

93 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
services:
postgres:
image: postgres:18
container_name: todo-postgres
environment:
POSTGRES_USER: todo
POSTGRES_PASSWORD: todo
POSTGRES_DB: todo
ports:
- "5432:5432"
volumes:
- ./data/pgsql:/var/lib/postgresql
redis:
image: redis:8.4
container_name: todo-redis
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
kafka:
image: apache/kafka:4.1.1
container_name: kafka
ports:
- "29092:29092"
environment:
# KRaft: broker + controller
KAFKA_NODE_ID: "1"
KAFKA_PROCESS_ROLES: "broker,controller"
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:9093"
# listeners
KAFKA_LISTENERS: "PLAINTEXT://0.0.0.0:9092,PLAINTEXT_HOST://0.0.0.0:29092,CONTROLLER://0.0.0.0:9093"
# 容器内访问使用 kafka:9092本机访问使用 localhost:29092
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,CONTROLLER:PLAINTEXT"
KAFKA_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
KAFKA_INTER_BROKER_LISTENER_NAME: "PLAINTEXT"
# 单节点开发用
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: "1"
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1"
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0"
volumes:
- ./data/kafka:/var/lib/kafka/data
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: todo-kafka-ui
ports:
- "8081:8080"
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
depends_on:
- kafka
api:
image: golang:1.26.0
container_name: todo-api
working_dir: /app
command: go run ./cmd/server
volumes:
- .:/app
ports:
- "8080:8080"
environment:
DATABASE_URL: postgres://todo:todo@postgres:5432/todo?sslmode=disable
REDIS_ADDR: redis:6379
KAFKA_BROKERS: kafka:9092
KAFKA_TOPIC: todo.tasks
NOTIFY_ENABLED: "true"
NOTIFY_TOPIC: notification.jobs
NOTIFY_DISPATCH_BATCH: "200"
NOTIFY_SCHED_TICK_SECONDS: "60"
NOTIFY_MAX_RETRY: "5"
NOTIFY_BACKOFF_BASE_SECONDS: "30"
SMTP_HOST: smtp.qq.com
SMTP_PORT: "465"
SMTP_USER:
SMTP_PASS:
SMTP_FROM:
SMTP_USE_TLS: "true"
GOPROXY: https://goproxy.cn,direct
GOSUMDB: "off"
AUTH_SECRET: dev-secret-change-me
depends_on:
- postgres
- redis
- kafka