Kafkatorio/docs/kafkatorio-platform/docker-compose.yml

151 lines
5.9 KiB
YAML
Raw Normal View History

## Kafkatorio, and optionally a Factorio server, on one Docker host.
##
## See docs/guide.md. In short:
## cp example.env .env # and edit it
## cp example.secret.kafkatorio-config.yml .secret.kafkatorio-config.yml # and edit it
## docker compose up -d # Kafkatorio only
## docker compose --profile factorio up -d # ... and the Factorio server
##
## All data is kept in this directory, so containers can be recreated (e.g. to upgrade) without
## losing the map.
name: kafkatorio
2022-10-30 17:21:32 +01:00
services:
## Kafka (KRaft mode). Only reachable by the other containers.
infra-kafka:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/kafka-kraft:${KAFKATORIO_VERSION}
container_name: kafkatorio-kafka
2022-10-30 17:21:32 +01:00
restart: unless-stopped
networks:
kafkatorio-nw:
aliases: [ kafka ]
2022-10-30 17:21:32 +01:00
volumes:
- "./config/kafka-server.properties:/kafka/server.properties:ro"
# fixed cluster ID, so the Kafka data survives image rebuilds
- "./config/cluster_id:/kafka/cluster_id:ro"
- "./kafka-data:/tmp/kraft-combined-logs"
2022-10-30 17:21:32 +01:00
## Processes Kafkatorio events (map tiles, buildings, resources...)
2022-10-30 17:21:32 +01:00
events-processors:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-processors:${KAFKATORIO_VERSION}
container_name: kafkatorio-events-processors
2022-10-30 17:21:32 +01:00
restart: unless-stopped
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
# one stream thread per partition (topics have 3)
KAFKA_STREAMS_NUM_THREADS: "3"
# merge repeated map-chunk updates for 10s before forwarding them (128MB cache per topology)
KAFKA_STREAMS_COMMIT_INTERVAL_MS: "10000"
KAFKA_STREAMS_CACHE_MAX_BYTES: "134217728"
# Sending the existing map (`/kafkatorio chunks 30`) needs a large heap for a while. G1 hands
# unused heap back to the OS when idle (G1PeriodicGCInterval). Lower -Xmx for small maps.
JAVA_OPTS: "-Xmx3g -XX:G1PeriodicGCInterval=60000 -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=10"
# off-heap memory shared by all RocksDB state stores
ROCKSDB_TOTAL_MEMORY_MB: "256"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
volumes:
- "./state/events-processors:/app/state"
2022-10-30 17:21:32 +01:00
secrets:
- source: kafkatorio_config
target: /.secret.config.yml
## Receives packets from the Factorio server, forwarded by the Docker syslog log driver.
## The log driver runs in the Docker daemon on the host, so if Factorio runs on this host,
## localhost-only is enough. If Factorio runs on another host, remove `127.0.0.1:` - and only
## allow that host in your firewall.
2022-10-30 17:21:32 +01:00
events-server-syslog:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-server-syslog:${KAFKATORIO_VERSION}
container_name: kafkatorio-events-server-syslog
2022-10-30 17:21:32 +01:00
restart: unless-stopped
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
JAVA_OPTS: "-Xmx256m -XX:G1PeriodicGCInterval=60000"
2022-10-30 17:21:32 +01:00
SOCKET_SERVER_HOST: "0.0.0.0"
SOCKET_SERVER_PORT: "9002"
ports:
- "127.0.0.1:12035:9002"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
2022-10-30 17:21:32 +01:00
secrets:
- source: kafkatorio_config
target: /.secret.config.yml
## Serves map tiles and other data, and sends live updates to browsers over a WebSocket
2022-10-30 17:21:32 +01:00
events-server-web:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-server-web:${KAFKATORIO_VERSION}
container_name: events-server-web # web-map's nginx proxies to this hostname
2022-10-30 17:21:32 +01:00
restart: unless-stopped
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
KAFKA_STREAMS_NUM_THREADS: "3"
JAVA_OPTS: "-Xmx768m -XX:G1PeriodicGCInterval=60000 -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=10"
2022-10-30 17:21:32 +01:00
WEB_SERVER_PORT: "80"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
volumes:
- "./data/events-server-web:/app/data"
- "./state/events-server-web:/app/state"
2022-10-30 17:21:32 +01:00
secrets:
- source: kafkatorio_config
target: /.secret.config.yml
## The website. Its nginx also proxies /kafkatorio/ to events-server-web, so a reverse proxy only
## needs to forward to this one port (with WebSocket support).
web-map:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/web-map:${KAFKATORIO_VERSION}
container_name: kafkatorio-web-map
2022-10-30 17:21:32 +01:00
restart: unless-stopped
ports:
- "12081:80"
networks: [ kafkatorio-nw ]
volumes:
# icons, names and the technology tree - see "Icons and names" in docs/guide.md
- "./icons:/usr/share/nginx/icons:ro"
2022-10-30 17:21:32 +01:00
## Kafka admin UI. Only on localhost: Kafka has no authentication, so don't expose this.
2022-10-30 17:21:32 +01:00
infra-kafka-ui:
image: provectuslabs/kafka-ui:v0.4.0
container_name: kafkatorio-kafka-ui
2022-10-30 17:21:32 +01:00
restart: unless-stopped
ports:
- "127.0.0.1:18090:8080"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
2022-10-30 17:21:32 +01:00
environment:
KAFKA_CLUSTERS_0_NAME: "kafkatorio"
2022-10-30 17:21:32 +01:00
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "kafka:29092"
## Optional: a Factorio server (start with `--profile factorio`).
## Put the kafkatorio-events mod zip in ./factorio-server/mods/
factorio-server:
image: factoriotools/factorio:${FACTORIO_VERSION}
container_name: kafkatorio-factorio-server
restart: unless-stopped
profiles: [ "factorio" ]
ports:
- "34197:34197/udp" # game
- "27015:27015/tcp" # RCON
volumes:
- "./factorio-server:/factorio"
# Docker won't start a container if its syslog server can't be reached, so start this last
depends_on: [ events-server-syslog ]
logging:
# forward the server log (which contains the mod's packets) to Kafkatorio
driver: syslog
options:
syslog-address: "tcp://127.0.0.1:12035"
syslog-format: "rfc5424"
mode: "non-blocking"
# the server's token (a JWT), which says which Kafkatorio server this is
tag: ${KAFKATORIO_TOKEN}
2022-10-30 17:21:32 +01:00
secrets:
kafkatorio_config:
file: ./.secret.kafkatorio-config.yml
networks:
kafkatorio-nw: