From 5eeedd50730c336b140b044225ec4cbbc2277844 Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Sun, 23 Jun 2024 15:40:54 +0200 Subject: [PATCH 1/2] feat: add a docker compose possibility --- Dockerfile | 2 +- docker-compose.yaml | 8 ++++++++ docker/entrypoint.sh | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yaml create mode 100755 docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index b2f490b..e9106f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ RUN make -C server re EXPOSE 4242 -CMD ["./zappy_server", "-p", "4242", "-n", "team1", "team2", "-l", "INFO", "--docker"] +ENTRYPOINT [ "./docker/entrypoint.sh" ] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..519b82b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +services: + poll: + build: . + restart: on-failure + ports: + - 4242:4242 + environment: + - ZAPPY_LOG_LEVEL=WARNING diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..735b4c9 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +LOG_LEVEL=${ZAPPY_LOG_LEVEL:-INFO} +TEAM_NAMES=${ZAPPY_TEAM_NAMES:-"team1 team2"} +CLIENT_NUMBER=${ZAPPY_CLIENT_NUMBER:-4} +FREQUENCY=${ZAPPY_FREQUENCY:-100} +DISPLAYER="server/base.so" +PORT=4242 +WIDTH=${ZAPPY_WIDTH:-10} +HEIGHT=${ZAPPY_HEIGHT:-10} + +./zappy_server -p $PORT -x $WIDTH -y $HEIGHT -n $TEAM_NAMES -c $CLIENT_NUMBER -f $FREQUENCY -d $DISPLAYER -l $LOG_LEVEL --docker From c08071feba73d21307017457bb1956bfafb10bb3 Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Sun, 23 Jun 2024 15:42:10 +0200 Subject: [PATCH 2/2] docs: document docker-compose --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 6d6ccf0..11e5c29 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,17 @@ It is advised to run `zappy_server` first - `clientsNb` is the number of authorized clients per team - `freq` is the reciprocal of time unit for execution of actions +It can also be runned using docker, by either building the image yourself or using the docker compose. + +If you want to configure the server using the docker compose you have access to multiple env vars: + +- `ZAPPY_LOG_LEVEL` for the log level `-l` +- `ZAPPY_TEAM_NAMES` for the team names `-n` +- `ZAPPY_CLIENT_NUMBER` for the client count `-c` +- `ZAPPY_FREQUENCY` for the frequency `-f` +- `ZAPPY_WIDTH` for the width `-x` +- `ZAPPY_HEIGHT` for the height `-y` + ## AI ```sh