From e61b3a9d90a13ea86a51b3c3c70f57b543721a90 Mon Sep 17 00:00:00 2001 From: arths31 Date: Sun, 28 Jul 2024 16:49:01 +0200 Subject: [PATCH 1/6] Add Docker support --- Dockerfile-Server | 16 +++++ Dockerfile-Web | 16 +++++ README.md | 16 +++++ docker-compose.yaml | 58 +++++++++++++++++++ tools/docker/server-entrypoint.sh | 16 +++++ tools/docker/web-entrypoint.sh | 17 ++++++ .../default-en/housekeeping/dashboard.tpl | 2 +- 7 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 Dockerfile-Server create mode 100644 Dockerfile-Web create mode 100644 docker-compose.yaml create mode 100644 tools/docker/server-entrypoint.sh create mode 100644 tools/docker/web-entrypoint.sh diff --git a/Dockerfile-Server b/Dockerfile-Server new file mode 100644 index 0000000..30232ed --- /dev/null +++ b/Dockerfile-Server @@ -0,0 +1,16 @@ +FROM eclipse-temurin:17-jdk AS builder + +WORKDIR /sources +COPY . /sources + +RUN ./gradlew build +RUN cd Havana-Server/build/distributions && tar xf Havana-Server.tar +RUN cd Havana-Server/build/distributions/Havana-Server/bin && ./Havana-Server + +FROM eclipse-temurin:17-jre +COPY --from=builder /sources/Havana-Server/build/distributions/Havana-Server /havana-server +COPY --from=builder /sources/figuredata.xml /havana-server/bin +COPY --from=builder /sources/tools/docker/server-entrypoint.sh /havana-server/bin/run.sh +WORKDIR /havana-server/bin +RUN chmod +x run.sh +ENTRYPOINT ["/havana-server/bin/run.sh"] diff --git a/Dockerfile-Web b/Dockerfile-Web new file mode 100644 index 0000000..6d4b031 --- /dev/null +++ b/Dockerfile-Web @@ -0,0 +1,16 @@ +FROM eclipse-temurin:17-jdk AS builder + +WORKDIR /sources +COPY . /sources + +RUN ./gradlew build +RUN cd Havana-Web/build/distributions && tar xf Havana-Web.tar +RUN cd Havana-Web/build/distributions/Havana-Web/bin && ./Havana-Web + +FROM eclipse-temurin:17-jre +COPY --from=builder /sources/Havana-Web/build/distributions/Havana-Web /havana-web +COPY --from=builder /sources/figuredata.xml /havana-web/bin +COPY --from=builder /sources/tools/docker/web-entrypoint.sh /havana-web/bin/run.sh +WORKDIR /havana-web/bin +RUN chmod +x run.sh +ENTRYPOINT ["/havana-web/bin/run.sh"] diff --git a/README.md b/README.md index 1a33a9b..d58cd8e 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,22 @@ Install the font manager, to enable the captcha to work on the website. apt-get install font-manager ``` +# Quick start using Docker + +Install Docker, update ``docker-compose.yaml`` to use strong passwords for MariaDB. + +❗ Variables values between ``x-mariadb-variables`` and ``x-havana-variables`` must match if you edit usernames and passwords. + +Download the [havana_www_28_07_2024.zip](https://www.mediafire.com/file/6kn4ghtb37lfc1p/havana_www_28_07_2024.zip/file) file, and then extract it to tools/www/ this directory is located in the repository you just cloned. + +Start the stack using ``docker-compose up`` + +You can access the MariaDB instance that is running in Docker on ``localhost:3306`` + +You can access Havana that is running in Docker on ``localhost:80`` + +Follow the instructions above for setting yourself as an admin. + ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..a76eb62 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,58 @@ +x-mariadb-variables: &mariadb-variables + MARIADB_USER: havana + MARIADB_PASSWORD: goldfish + MARIADB_ROOT_PASSWORD: yourstrongpassword + MARIADB_DATABASE: havana + +x-havana-variables: &havana-variables + MYSQL_USERNAME: havana + MYSQL_PASSWORD: goldfish + MYSQL_DATABASE: havana + +services: + havana-server: + depends_on: + mariadb: + condition: service_healthy + build: + context: . + dockerfile: Dockerfile-Server + ports: + - "12321:12321" + - "12309:12309" + - "12322:12322" + environment: + <<: *havana-variables + restart: on-failure + havana-web: + depends_on: + mariadb: + condition: service_healthy + build: + context: . + dockerfile: Dockerfile-Web + ports: + - "80:80" + volumes: + - ./tools:/havana-web/bin/tools + environment: + <<: *havana-variables + restart: on-failure + mariadb: + image: "mariadb:latest" + ports: + - "3306:3306" + environment: + <<: *mariadb-variables + volumes: + - data:/var/lib/mysql + - ./tools/havana.sql:/docker-entrypoint-initdb.d/havana.sql + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 + restart: on-failure +volumes: + data: diff --git a/tools/docker/server-entrypoint.sh b/tools/docker/server-entrypoint.sh new file mode 100644 index 0000000..0a8c20c --- /dev/null +++ b/tools/docker/server-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +MYSQL_HOSTNAME="${MYSQL_HOSTNAME:-mariadb}" +MYSQL_PORT="${MYSQL_PORT:-3306}" +MYSQL_USERNAME="${MYSQL_USERNAME:-root}" +MYSQL_PASSWORD="${MYSQL_PASSWORD:-goldfish}" +MYSQL_DATABASE="${MYSQL_DATABASE:-havana}" + +sed -i -E "s/(mysql.hostname=)(.*)/\1$MYSQL_HOSTNAME/g" server.ini +sed -i -E "s/(mysql.port=)(.*)/\1$MYSQL_PORT/g" server.ini +sed -i -E "s/(mysql.username=)(.*)/\1$MYSQL_USERNAME/g" server.ini +sed -i -E "s/(mysql.password=)(.*)/\1$MYSQL_PASSWORD/g" server.ini +sed -i -E "s/(mysql.database=)(.*)/\1$MYSQL_DATABASE/g" server.ini +sed -i -E "s/(rcon.bind=)(.*)/\10.0.0.0/g" server.ini + +./Havana-Server diff --git a/tools/docker/web-entrypoint.sh b/tools/docker/web-entrypoint.sh new file mode 100644 index 0000000..fd8a721 --- /dev/null +++ b/tools/docker/web-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +RCON_IP="${RCON_IP:-havana-server}" +MYSQL_HOSTNAME="${MYSQL_HOSTNAME:-mariadb}" +MYSQL_PORT="${MYSQL_PORT:-3306}" +MYSQL_USERNAME="${MYSQL_USERNAME:-root}" +MYSQL_PASSWORD="${MYSQL_PASSWORD:-goldfish}" +MYSQL_DATABASE="${MYSQL_DATABASE:-havana}" + +sed -i -E "s/(mysql.hostname=)(.*)/\1$MYSQL_HOSTNAME/g" webserver-config.ini +sed -i -E "s/(mysql.port=)(.*)/\1$MYSQL_PORT/g" webserver-config.ini +sed -i -E "s/(mysql.username=)(.*)/\1$MYSQL_USERNAME/g" webserver-config.ini +sed -i -E "s/(mysql.password=)(.*)/\1$MYSQL_PASSWORD/g" webserver-config.ini +sed -i -E "s/(mysql.database=)(.*)/\1$MYSQL_DATABASE/g" webserver-config.ini +sed -i -E "s/(rcon.ip=)(.*)/\1$RCON_IP/g" webserver-config.ini + +./Havana-Web diff --git a/tools/www-tpl/default-en/housekeeping/dashboard.tpl b/tools/www-tpl/default-en/housekeeping/dashboard.tpl index 44a63eb..ed6dcc4 100644 --- a/tools/www-tpl/default-en/housekeeping/dashboard.tpl +++ b/tools/www-tpl/default-en/housekeeping/dashboard.tpl @@ -88,7 +88,7 @@ {% for player in players %} {{ player.id }} - {{ player.name }} - Transactons + {{ player.name }} - Transactions {{ player.email }} {% autoescape 'html' %} From c1224885e3ecb732021a46edf049bfa0419fe135 Mon Sep 17 00:00:00 2001 From: arths31 Date: Sun, 28 Jul 2024 17:51:29 +0200 Subject: [PATCH 2/6] Fix wrong binding of server ports --- tools/docker/server-entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/docker/server-entrypoint.sh b/tools/docker/server-entrypoint.sh index 0a8c20c..b426810 100644 --- a/tools/docker/server-entrypoint.sh +++ b/tools/docker/server-entrypoint.sh @@ -12,5 +12,7 @@ sed -i -E "s/(mysql.username=)(.*)/\1$MYSQL_USERNAME/g" server.ini sed -i -E "s/(mysql.password=)(.*)/\1$MYSQL_PASSWORD/g" server.ini sed -i -E "s/(mysql.database=)(.*)/\1$MYSQL_DATABASE/g" server.ini sed -i -E "s/(rcon.bind=)(.*)/\10.0.0.0/g" server.ini +sed -i -E "s/(server.bind=)(.*)/\10.0.0.0/g" server.ini +sed -i -E "s/(mus.bind=)(.*)/\10.0.0.0/g" server.ini ./Havana-Server From 7a4cc55375e7372a34f76deaa988607ff2124d54 Mon Sep 17 00:00:00 2001 From: arths31 Date: Mon, 29 Jul 2024 13:27:42 +0200 Subject: [PATCH 3/6] Don't bind RCON port to host --- docker-compose.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index a76eb62..2d4fecb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -19,7 +19,6 @@ services: dockerfile: Dockerfile-Server ports: - "12321:12321" - - "12309:12309" - "12322:12322" environment: <<: *havana-variables From de5be74dbf7bc386f76009c9cd6dd1b875fb57a9 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 29 Jul 2024 14:07:02 +0200 Subject: [PATCH 4/6] Update docker-compose to use named network for minerva --- docker-compose.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 2d4fecb..c8ca7b8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -20,6 +20,8 @@ services: ports: - "12321:12321" - "12322:12322" + networks: + - havana environment: <<: *havana-variables restart: on-failure @@ -32,6 +34,8 @@ services: dockerfile: Dockerfile-Web ports: - "80:80" + networks: + - havana volumes: - ./tools:/havana-web/bin/tools environment: @@ -41,6 +45,8 @@ services: image: "mariadb:latest" ports: - "3306:3306" + networks: + - havana environment: <<: *mariadb-variables volumes: @@ -53,5 +59,9 @@ services: timeout: 5s retries: 3 restart: on-failure + volumes: data: + +networks: + havana: From 07432961723cde342ed7c9582b9925f0ce3e8ffd Mon Sep 17 00:00:00 2001 From: arths31 <119982607+arths31@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:41:37 +0200 Subject: [PATCH 5/6] Update Dockerfile-Server to stop copying everything --- Dockerfile-Server | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile-Server b/Dockerfile-Server index 30232ed..87d866b 100644 --- a/Dockerfile-Server +++ b/Dockerfile-Server @@ -1,7 +1,12 @@ FROM eclipse-temurin:17-jdk AS builder WORKDIR /sources -COPY . /sources +COPY ./gradle /sources/gradle +COPY ./gradlew /sources +COPY ./figuredata.xml /sources +COPY ./tools/docker /sources/tools/docker +COPY ./Havana-Server/ /sources/Havana-Server +COPY ./settings.gradle /sources RUN ./gradlew build RUN cd Havana-Server/build/distributions && tar xf Havana-Server.tar From b58da0db2adc39a37bb535c3c66d94600e714b3b Mon Sep 17 00:00:00 2001 From: arths31 <119982607+arths31@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:42:31 +0200 Subject: [PATCH 6/6] Update Dockerfile-Web to stop copying everything --- Dockerfile-Server | 2 +- Dockerfile-Web | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile-Server b/Dockerfile-Server index 87d866b..ad5cc72 100644 --- a/Dockerfile-Server +++ b/Dockerfile-Server @@ -4,7 +4,7 @@ WORKDIR /sources COPY ./gradle /sources/gradle COPY ./gradlew /sources COPY ./figuredata.xml /sources -COPY ./tools/docker /sources/tools/docker +COPY ./tools/docker/server-entrypoint.sh /sources/tools/docker/server-entrypoint.sh COPY ./Havana-Server/ /sources/Havana-Server COPY ./settings.gradle /sources diff --git a/Dockerfile-Web b/Dockerfile-Web index 6d4b031..1ec198b 100644 --- a/Dockerfile-Web +++ b/Dockerfile-Web @@ -1,7 +1,13 @@ FROM eclipse-temurin:17-jdk AS builder WORKDIR /sources -COPY . /sources +COPY ./gradle /sources/gradle +COPY ./gradlew /sources +COPY ./figuredata.xml /sources +COPY ./tools/docker/web-entrypoint.sh /sources/tools/docker/web-entrypoint.sh +COPY ./Havana-Server/ /sources/Havana-Server +COPY ./Havana-Web/ /sources/Havana-Web +COPY ./settings.gradle /sources RUN ./gradlew build RUN cd Havana-Web/build/distributions && tar xf Havana-Web.tar