Skip to content

Commit

Permalink
Merge pull request #50 from arths31/docker
Browse files Browse the repository at this point in the history
Add Docker support
  • Loading branch information
Quackster authored Aug 15, 2024
2 parents ced318e + b58da0d commit 09f0b1d
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Dockerfile-Server
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM eclipse-temurin:17-jdk AS builder

WORKDIR /sources
COPY ./gradle /sources/gradle
COPY ./gradlew /sources
COPY ./figuredata.xml /sources
COPY ./tools/docker/server-entrypoint.sh /sources/tools/docker/server-entrypoint.sh
COPY ./Havana-Server/ /sources/Havana-Server
COPY ./settings.gradle /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"]
22 changes: 22 additions & 0 deletions Dockerfile-Web
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM eclipse-temurin:17-jdk AS builder

WORKDIR /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
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"]
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
67 changes: 67 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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"
- "12322:12322"
networks:
- havana
environment:
<<: *havana-variables
restart: on-failure
havana-web:
depends_on:
mariadb:
condition: service_healthy
build:
context: .
dockerfile: Dockerfile-Web
ports:
- "80:80"
networks:
- havana
volumes:
- ./tools:/havana-web/bin/tools
environment:
<<: *havana-variables
restart: on-failure
mariadb:
image: "mariadb:latest"
ports:
- "3306:3306"
networks:
- havana
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:

networks:
havana:
18 changes: 18 additions & 0 deletions tools/docker/server-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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
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
17 changes: 17 additions & 0 deletions tools/docker/web-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/www-tpl/default-en/housekeeping/dashboard.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{% for player in players %}
<tr>
<td>{{ player.id }}</td>
<td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a> - <a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/transaction/lookup?searchQuery={{ player.getName() }}">Transactons</a></td>
<td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a> - <a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/transaction/lookup?searchQuery={{ player.getName() }}">Transactions</a></td>
<td>{{ player.email }}</td>
<td><img src="{{ site.sitePath }}/habbo-imaging/avatarimage?figure={{ player.figure }}&size=s"></td>
{% autoescape 'html' %}
Expand Down

0 comments on commit 09f0b1d

Please sign in to comment.