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>
This commit is contained in:
Lazzexus 2026-11-22 10:36:01 +01:00
parent 9bdb6a5812
commit 1f4786c1bd
4 changed files with 447 additions and 228 deletions

View file

@ -1,145 +1,150 @@
version: "3.9"
## 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:
## Factorio game server that players will connect to
factorio-server:
image: factoriotools/factorio:${FACTORIO_VERSION}
container_name: "factorio-server"
## 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
profiles: [ "factorio", "kafkatorio" ]
networks:
- kafkatorio-infra-nw
ports:
- "34198:34197/udp" # factorio
- "27016:27015/tcp" # rcon
kafkatorio-nw:
aliases: [ kafka ]
volumes:
- "./factorio-server:/factorio"
logging:
# set up syslog, so logs can be forwarded to Kafkatorio
driver: syslog
options:
syslog-address: ${SYSLOG_ADDRESS}
syslog-format: "rfc5424"
# set the tag to be a JWT, containing the server short-ID
tag: ${KAFKATORIO_TOKEN}
- "./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"
## Kafkatorio Web Map host
web-map:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/web-map:${KAFKATORIO_VERSION}
container_name: web-map
profiles: [ "infra", "kafkatorio" ]
restart: unless-stopped
ports:
- "12081:80" # web map (also proxies /kafkatorio/ to events-server-web)
networks:
- kafkatorio-infra-nw
# volumes:
# # building icons - see building-icons/export_building_icons.py
# - "./icons:/usr/share/nginx/icons:ro"
## Process Kafkatorio events
## Processes Kafkatorio events (map tiles, buildings, resources...)
events-processors:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-processors:${KAFKATORIO_VERSION}
container_name: events-processors
container_name: kafkatorio-events-processors
restart: unless-stopped
profiles: [ "infra", "kafkatorio" ]
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
networks:
- kafkatorio-infra-nw
depends_on:
- infra-kafka
# 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 via Docker syslog-plugin
## 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: events-server-syslog
container_name: kafkatorio-events-server-syslog
restart: unless-stopped
profiles: [ "infra", "kafkatorio" ]
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
JAVA_OPTS: "-Xmx256m -XX:G1PeriodicGCInterval=60000"
SOCKET_SERVER_HOST: "0.0.0.0"
SOCKET_SERVER_PORT: "9002"
ports:
- "12035:9002" # syslog socket
networks:
- kafkatorio-infra-nw
depends_on:
- infra-kafka
- events-processors
- "127.0.0.1:12035:9002"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
secrets:
- source: kafkatorio_config
target: /.secret.config.yml
## Hosts map-tiles and forwards websocket messages to the web-map browsers
## 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
container_name: events-server-web # web-map's nginx proxies to this hostname
restart: unless-stopped
profiles: [ "infra", "kafkatorio" ]
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"
ports:
- "12080:80" # http and ws
networks:
- kafkatorio-infra-nw
depends_on:
- infra-kafka
- events-processors
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
## An instance of Kafka
infra-kafka:
image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/kafka-kraft:${KAFKATORIO_VERSION}
container_name: infra-kafka
## 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
profiles: [ "infra", "kafka" ]
networks:
kafkatorio-infra-nw:
aliases: [ kafka ]
volumes:
- "./config/kafka-server.properties:/kafka/server.properties"
ports:
# note: other Docker containers should use 29092
- "9092:9092"
- "9093:9093"
- "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"
## web-based GUI for Kafka
## 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: infra-kafka-ui
container_name: kafkatorio-kafka-ui
restart: unless-stopped
profiles: [ "infra", "kafka" ]
networks:
- kafkatorio-infra-nw
ports:
- "18090:8080"
depends_on:
- infra-kafka
- "127.0.0.1:18090:8080"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
environment:
KAFKA_CLUSTERS_0_NAME: "${COMPOSE_PROJECT_NAME}"
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-infra-nw:
kafkatorio-game-nw:
kafkatorio-nw:

View file

@ -1,10 +1,12 @@
# Docker Compose containers config
COMPOSE_PROJECT_NAME=Kafkatorio
KAFKATORIO_TOKEN=<jwt token>
KAFKATORIO_VERSION=0.9.15
# Docker Compose settings - copy to `.env`
# the version of the Kafkatorio images you built (the `version` in build.gradle.kts)
KAFKATORIO_VERSION=0.10.1
# images are built locally, and tagged `localhost/dev.adamko.kafkatorio/...`
REGISTRY_HOST=localhost
SYSLOG_ADDRESS=tcp://www.my-website.com:12345
# Only needed for the optional Factorio server (`docker compose --profile factorio up -d`)
# A factoriotools/factorio tag: https://hub.docker.com/r/factoriotools/factorio
FACTORIO_VERSION=stable
# The Factorio server's token - see "Create a token for the Factorio server" in docs/guide.md
KAFKATORIO_TOKEN=<jwt token>