tidy up and some docs

This commit is contained in:
Adam 2021-10-23 23:08:26 +02:00
parent 361ed8eef7
commit e526345299
2 changed files with 50 additions and 34 deletions

View file

@ -12,41 +12,10 @@ services:
FACTORIO_SERVER_CONTAINER_NAME: "factorio-server"
KAFKA_HOST: "kafka:29092"
volumes:
# Unix and Windows?
# - "//./pipe/docker_engine:/var/run/docker.sock"
# - "//./pipe/docker_engine:/pipe/docker_engine"
# Windows (requires privileged/root)
- "//var/run/docker.sock:/var/run/docker.sock"
# - "/var/run/docker.sock:/var/run/docker.sock"
# Windows?
# - "\\.\\pipe\\docker_engine:\\.\\pipe\\docker_engine"
# Windows?
# - "/usr/local/bin/docker:/usr/bin/docker"
# kp3:
# image: edenhill/kcat:1.7.0
# container_name: kafka-pipe3
# networks:
# - "factorio-events-nw"
# volumes:
# - "./kafka-pipe.sh:/kafka-pipe.sh"
# entrypoint:
# # - "ls"
# # - "-la"
# # - "&&"
# - "/bin/sh"
# - "./kafka-pipe.sh"
# - "factorio-server"
# - "kafka-kraft"
###
# volumes:
# - "./build/libs/:/app"
# command:
# - "java"
# - "-jar"
# - "/app/pipe-docker-logs-to-kafka-0.0.2.jar"
# Unix?
# - "/var/run/docker.sock:/var/run/docker.sock"
networks:
factorio-events-nw:

View file

@ -0,0 +1,47 @@
### Setup notes
Kafka must be connectable from both `localhost` (for cli) and `kafa` (the docker container name).
### Useful commands
#### Powershell
```shell
# might help with mounting the unix socket on Windows?
$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1
# full rebuild
docker-compose down; docker-compose build; docker-compose up -d; docker-compose logs -f
```
#### zsh
```shell
# listen to events from factorio-server
docker logs --tail 0 -f factorio-server | sed -n -e 's/^FactorioEvent: //p'
# tail logs with docker api (except it doesn't work)
curl -vvv \
--unix-socket /var/run/docker.sock \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: localhost:80" \
--header "Origin: http://localhost:80" \
--header "Sec-WebSocket-Version: 13" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
"http://localhost:80/v1.41/containers/factorio-server/attach/ws?stream=true&logs=true&stdout=true"
# tail logs
curl --no-buffer -sS --unix-socket /var/run/docker.sock \
--get --data-urlencode 'filters={"container":["my-service"]}' \
"http://localhost/v1.41/events" | jq --unbuffered
# get logs from Kafka
kafkacat -u -C -b localhost -t factorio-server-log | jq --unbuffered
```