Kafkatorio/docs/kafkatorio-platform/docker-compose.yml
Lazzexus 1f4786c1bd Rewrite the README and setup guide, and fix the example Compose setup
The README describes what Kafkatorio does now (the live map, production
and research pages), that this is a Factorio 2.0 fork, and how the
services fit together.

The guide is rewritten as numbered steps, from building the images to a
public website: configuration, creating the server's token locally
(instead of typing the secret into jwt.io), connecting the Factorio
server's log, sending the existing map, exporting icons and names, and
the reverse proxy. Also: the Unraid setup, updating, and troubleshooting.

It warns that the mod portal's kafkatorio-events is the original, for
Factorio 1.1, with overlapping version numbers, so players must install
the mod zip by hand.

The example docker-compose.yml lost all data when containers were
recreated (e.g. on every update), and exposed Kafka, which has no
authentication, on all interfaces. It's now based on the Unraid setup:
Kafka data, map tiles, state and icons are kept next to it, only the
website is exposed, and the optional Factorio server (--profile factorio)
starts after the syslog server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:36:01 +01:00

150 lines
5.9 KiB
YAML

## 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
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
restart: unless-stopped
networks:
kafkatorio-nw:
aliases: [ kafka ]
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"
## Processes Kafkatorio events (map tiles, buildings, resources...)
events-processors:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-processors:${KAFKATORIO_VERSION}
container_name: kafkatorio-events-processors
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"
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.
events-server-syslog:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-server-syslog:${KAFKATORIO_VERSION}
container_name: kafkatorio-events-server-syslog
restart: unless-stopped
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
JAVA_OPTS: "-Xmx256m -XX:G1PeriodicGCInterval=60000"
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 ]
secrets:
- source: kafkatorio_config
target: /.secret.config.yml
## Serves map tiles and other data, and sends live updates to browsers over a WebSocket
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
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"
WEB_SERVER_PORT: "80"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
volumes:
- "./data/events-server-web:/app/data"
- "./state/events-server-web:/app/state"
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
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"
## Kafka admin UI. Only on localhost: Kafka has no authentication, so don't expose this.
infra-kafka-ui:
image: provectuslabs/kafka-ui:v0.4.0
container_name: kafkatorio-kafka-ui
restart: unless-stopped
ports:
- "127.0.0.1:18090:8080"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
environment:
KAFKA_CLUSTERS_0_NAME: "kafkatorio"
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}
secrets:
kafkatorio_config:
file: ./.secret.kafkatorio-config.yml
networks:
kafkatorio-nw: