Skip to content

Commit d3f92b8

Browse files
committed
feature: add docker support
1 parent c941363 commit d3f92b8

File tree

18 files changed

+572
-40
lines changed

18 files changed

+572
-40
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git
2+
.github/
3+
.env*
4+
compose*yaml
5+
Dockerfile
6+
.dockerignore

.env.aowow.dist

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## mysql specific environment
2+
MYSQL_HOST=mysql
3+
## keep as same as `DB_AOWOW_USER`
4+
MYSQL_USER=root
5+
## keep as same as `DB_AOWOW_PASS`
6+
MYSQL_PWD=root
7+
## keep as same as `DB_AOWOW_DB`
8+
MYSQL_DATABASE=aowow
9+
10+
## aowow specific environment
11+
HTTP_HOST=172.28.0.10
12+
HTTP_PORT=8117
13+
14+
DB_AOWOW_HOST=mysql
15+
DB_AOWOW_PORT=3306
16+
DB_AOWOW_USER=root
17+
DB_AOWOW_PASS=root
18+
DB_AOWOW_DB=aowow
19+
DB_AOWOW_PREFIX=aowow_
20+
21+
DB_WORLD_HOST=mysql
22+
DB_WORLD_PORT=3306
23+
DB_WORLD_USER=root
24+
DB_WORLD_PASS=root
25+
DB_WORLD_DB=trinitycore_world
26+
DB_WORLD_PREFIX=
27+
28+
DB_AUTH_HOST=mysql
29+
DB_AUTH_PORT=3306
30+
DB_AUTH_USER=root
31+
DB_AUTH_PASS=root
32+
DB_AUTH_DB=trinitycore_auth
33+
DB_AUTH_PREFIX=
34+
35+
DB_CHARACTERS_1_HOST=mysql
36+
DB_CHARACTERS_1_PORT=3306
37+
DB_CHARACTERS_1_USER=root
38+
DB_CHARACTERS_1_PASS=root
39+
DB_CHARACTERS_1_DB=trinitycore_characters
40+
DB_CHARACTERS_1_PREFIX=
41+
42+
## Setup
43+
SETUP_SKIP=0
44+
SETUP_EXTRACTED_DATA_ARCHIVE_URL=https://github.com/wowgaming/client-data/releases/download/v16/data.zip
45+
SETUP_MPQ_DATA_INTERFACE_URL=https://raw.githubusercontent.com/wowgaming/3.3.5-interface-files/refs/heads/main/GlobalStrings.lua
46+
47+
## Notice: if you are debugging docker container, better to host files locally instead of download everytime files from internet.
48+
## for example: cd ~/Documents/data-for-aowow-application; python3 -m http.server`
49+
# SETUP_MPQ_DATA_INTERFACE_URL=http://host.docker.internal:8000/GlobalStrings.lua
50+
# SETUP_EXTRACTED_DATA_ARCHIVE_URL=http://host.docker.internal:8000/data.zip

.env.mysql.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## mysql specific environment
2+
MYSQL_ROOT_PASSWORD=root
3+
4+
## aowow specific environment
5+
## keep as same as in `.env.aowow`
6+
DB_AOWOW_USER=root
7+
DB_AOWOW_PASS=root
8+
DB_WORLD_DB=trinitycore_world
9+
DB_AUTH_DB=trinitycore_auth
10+
DB_CHARACTERS_1_DB=trinitycore_characters
11+
12+
## Setup
13+
SETUP_SKIP=0
14+
SETUP_WORLD_DATABASE_DUMP_URL=https://github.com/TrinityCore/TrinityCore/releases/download/TDB335.21101/TDB_full_world_335.21101_2021_10_15.7z
15+
SETUP_AUTH_DATABASE_DUMP_URL=https://raw.githubusercontent.com/TrinityCore/TrinityCore/refs/heads/3.3.5/sql/base/auth_database.sql
16+
SETUP_CHARACTERS_DATABASE_DUMP_URL=https://raw.githubusercontent.com/TrinityCore/TrinityCore/refs/heads/3.3.5/sql/base/characters_database.sql
17+
18+
## Notice: if you are debugging docker container, better to host files locally instead of download everytime files from internet.
19+
## for example: cd ~/Documents/data-for-aowow-application; python3 -m http.server`
20+
# SETUP_WORLD_DATABASE_DUMP_URL=http://host.docker.internal:8000/mysql/TDB_full_world_335.21101_2021_10_15.7z
21+
# SETUP_AUTH_DATABASE_DUMP_URL=http://host.docker.internal:8000/mysql/auth_database.sql
22+
# SETUP_CHARACTERS_DATABASE_DUMP_URL=http://host.docker.internal:8000/mysql/characters_database.sql

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Environment
2+
.env*
3+
!.env*dist
4+
15
# Git
26
*.orig
37

.htaccess

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ Order Deny,Allow
22
<FilesMatch "\.(conf|php|in)$">
33
Deny from all
44
</FilesMatch>
5+
6+
<FilesMatch "\.(yaml|env|md|dist)$">
7+
Deny from all
8+
</FilesMatch>
9+
510
<FilesMatch "^(index)\.php$">
611
Allow from all
712
</FilesMatch>

Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
FROM php:8.2-apache AS php-base
2+
3+
RUN <<EOF
4+
set -aeux
5+
apt-get update
6+
apt-get install -y --no-install-recommends --no-install-suggests \
7+
libfreetype-dev \
8+
libjpeg62-turbo-dev \
9+
libpng-dev \
10+
libonig-dev \
11+
libxml2-dev \
12+
libicu-dev \
13+
libgmp-dev \
14+
default-mysql-client \
15+
libarchive-tools
16+
EOF
17+
18+
RUN <<EOF
19+
docker-php-ext-configure gd --with-freetype --with-jpeg
20+
docker-php-ext-install -j$(nproc) gd mbstring xml pdo_mysql mysqli intl gmp
21+
EOF
22+
23+
RUN a2enmod rewrite
24+
25+
COPY ./docker/aowow/usr/local/bin/* /usr/local/bin
26+
27+
WORKDIR /var/www/html
28+
29+
CMD ["/usr/local/bin/entrypoint.sh"]
30+
31+
FROM php-base AS php-dev
32+
33+
# fixme: workaround to ignore TLS error on connection to mysql from aowow service: fix it correctly, instead ignoring
34+
COPY './docker/aowow/(home)/.my.cnf' /root
35+
36+
FROM php-base AS php-prod
37+
38+
COPY . .
39+
40+
FROM mariadb:12.0 AS mariadb-dev
41+
42+
RUN apt update && apt-get install p7zip curl -y
43+
RUN ln -s /usr/bin/mariadb /usr/bin/mysql
44+
45+
HEALTHCHECK --interval=5s --timeout=5s --retries=30 CMD mariadb-admin ping -h 127.0.0.1 -u root -P3306 -p$MYSQL_ROOT_PASSWORD || exit 1
46+
47+
# DEPRECATED: consider to don't use
48+
FROM mysql:5.7-debian AS mysql-dev
49+
RUN <<EOF
50+
set -aeu
51+
52+
cat << 'EOL' > /etc/apt/sources.list
53+
deb http://archive.debian.org/debian buster main contrib non-free
54+
deb http://archive.debian.org/debian-security buster/updates main contrib non-free
55+
deb http://archive.debian.org/debian buster-updates main contrib non-free
56+
EOL
57+
58+
# cat /etc/apt/sources.list.d/mysql.list
59+
#curl https://repo.mysql.com/RPM-GPG-KEY-mysql | apt-key add -
60+
#apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 B7B3B788A8D3785C
61+
#apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
62+
#gpg --recv-keys B7B3B788A8D3785C
63+
#gpg --export B7B3B788A8D3785C | apt-key add -
64+
65+
apt-get update -y --allow-insecure-repositories
66+
apt-get install p7zip-full curl -y
67+
EOF
68+
69+
HEALTHCHECK --interval=5s --timeout=5s --retries=30 CMD mysqladmin ping -h 127.0.0.1 -u root -P3306 -p$MYSQL_ROOT_PASSWORD || exit 1

README.md

Lines changed: 133 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
![logo](static/images/logos/home.png)
22

3-
43
## Build Status
5-
![fuck it ship it](http://forthebadge.com/images/badges/fuck-it-ship-it.svg)
64

5+
![fuck it ship it](http://forthebadge.com/images/badges/fuck-it-ship-it.svg)
76

87
## Introduction
98

@@ -15,57 +14,81 @@ This is a complete rewrite of the serverside php code and update to the clientsi
1514
I myself take no credit for the clientside scripting, design and layout that these php-scripts cater to.
1615
Also, this project is not meant to be used for commercial purposes of any kind!
1716

18-
1917
## Requirements
2018

21-
+ Webserver running PHP ≥ 8.2 including extensions:
22-
+ [SimpleXML](https://www.php.net/manual/en/book.simplexml.php)
23-
+ [GD](https://www.php.net/manual/en/book.image)
24-
+ [MySQL Improved](https://www.php.net/manual/en/book.mysqli.php)
25-
+ [Multibyte String](https://www.php.net/manual/en/book.mbstring.php)
26-
+ [File Information](https://www.php.net/manual/en/book.fileinfo.php)
27-
+ [Internationalization](https://www.php.net/manual/en/book.intl.php)
28-
+ [GNU Multiple Precision](https://www.php.net/manual/en/book.gmp.php) (When using TrinityCore as auth source)
29-
+ MySQL ≥ 5.7.0 OR MariaDB ≥ 10.6.4 OR similar
30-
+ [TDB 335.21101](https://github.com/TrinityCore/TrinityCore/releases/tag/TDB335.21101) (no other other providers are supported at this time)
31-
+ WIN: php.exe needs to be added to the `PATH` system variable, if it isn't already.
32-
+ Tools require cmake: Please refer to the individual repositories for detailed information
33-
+ [MPQExtractor](https://github.com/Sarjuuk/MPQExtractor) / [FFmpeg](https://ffmpeg.org/download.html) / (optional: [BLPConverter](https://github.com/Sarjuuk/BLPConverter))
34-
+ WIN users may find it easier to use these alternatives
35-
+ [MPQEditor](http://www.zezula.net/en/mpq/download.html) / [FFmpeg](http://ffmpeg.zeranoe.com/builds/) / (optional: [BLPConverter](https://github.com/PatrickCyr/BLPConverter))
19+
- Webserver running PHP ≥ 8.2 including extensions:
20+
- [SimpleXML](https://www.php.net/manual/en/book.simplexml.php)
21+
- [GD](https://www.php.net/manual/en/book.image)
22+
- [MySQL Improved](https://www.php.net/manual/en/book.mysqli.php)
23+
- [Multibyte String](https://www.php.net/manual/en/book.mbstring.php)
24+
- [File Information](https://www.php.net/manual/en/book.fileinfo.php)
25+
- [Internationalization](https://www.php.net/manual/en/book.intl.php)
26+
- [GNU Multiple Precision](https://www.php.net/manual/en/book.gmp.php) (When using TrinityCore as auth source)
27+
- MySQL ≥ 5.7.0 OR MariaDB ≥ 10.6.4 OR similar
28+
- [TDB 335.21101](https://github.com/TrinityCore/TrinityCore/releases/tag/TDB335.21101) (no other other providers are supported at this time)
29+
- WIN: php.exe needs to be added to the `PATH` system variable, if it isn't already.
30+
- Tools require cmake: Please refer to the individual repositories for detailed information
31+
- [MPQExtractor](https://github.com/Sarjuuk/MPQExtractor) / [FFmpeg](https://ffmpeg.org/download.html) / (optional: [BLPConverter](https://github.com/Sarjuuk/BLPConverter))
32+
- WIN users may find it easier to use these alternatives
33+
- [MPQEditor](http://www.zezula.net/en/mpq/download.html) / [FFmpeg](http://ffmpeg.zeranoe.com/builds/) / (optional: [BLPConverter](https://github.com/PatrickCyr/BLPConverter))
3634

3735
audio processing may require [lame](https://sourceforge.net/projects/lame/files/lame/3.99/) or [vorbis-tools](https://www.xiph.org/downloads/) (which may require libvorbis (which may require libogg))
3836

39-
4037
#### Highly Recommended
41-
+ setting the following configuration values on your TrinityCore server will greatly increase the accuracy of spawn points
38+
39+
- setting the following configuration values on your TrinityCore server will greatly increase the accuracy of spawn points
4240
> Calculate.Creature.Zone.Area.Data = 1
4341
> Calculate.Gameobject.Zone.Area.Data = 1
4442
45-
4643
## Install
44+
### 1. Acquire the required repositories
4745

48-
#### 1. Acquire the required repositories
49-
`git clone [email protected]:Sarjuuk/aowow.git aowow`
50-
`git clone [email protected]:Sarjuuk/MPQExtractor.git MPQExtractor`
46+
```sh
47+
git clone [email protected]:Sarjuuk/aowow.git aowow
48+
git clone [email protected]:Sarjuuk/MPQExtractor.git MPQExtractor
49+
```
50+
51+
### 2. Prepare the database
5152

52-
#### 2. Prepare the database
5353
Ensure that the account you are going to use has **full** access on the database AoWoW is going to occupy and ideally only **read** access on the world database you are going to reference.
5454
Import files 01 - 03 from `setup/sql/` in order into the AoWoW database `mysql -p {your-db-here} < setup/sql/01-db_structure.sql`, etc.
5555

56-
#### 3. Server created files
56+
### 3. Server created files
57+
5758
See to it, that the web server is able to write the following directories and their children. If they are missing, the setup will create them with appropriate permissions
58-
* `cache/`
59-
* `config/`
60-
* `static/download/`
61-
* `static/widgets/`
62-
* `static/js/`
63-
* `static/uploads/`
64-
* `static/images/wow/`
65-
* `datasets/`
66-
67-
#### 4. Extract the client archives (MPQs)
68-
Extract the following directories from the client archives into `setup/mpqdata/`, while maintaining patch order (base mpq -> patch-mpq: 1 -> 9 -> A -> Z). The required paths are scattered across the archives. Overwrite older files if asked to.
59+
60+
- `cache/`
61+
- `config/`
62+
- `static/download/`
63+
- `static/widgets/`
64+
- `static/js/`
65+
- `static/uploads/`
66+
- `static/images/wow/`
67+
- `datasets/`
68+
69+
### 4. Extract the client archives (MPQs)
70+
71+
Extract the following directories from the client archives into `setup/mpqdata/`,
72+
while maintaining patch order (base mpq -> patch-mpq: 1 -> 9 -> A -> Z).
73+
The required paths are scattered across the archives. Overwrite older files if asked to.
74+
75+
```sh
76+
WOW_DIR='/.../World Of Warcraft 3.3.5a'
77+
OUT_DIR='/.../aowow/setup/mpqdata'
78+
locale='enUS'
79+
80+
mkdir -p "$OUT_DIR"
81+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/common.MPQ" -e "*"
82+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/common-2.MPQ" -e "*"
83+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/expansion.MPQ" -e "*"
84+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/lichking.MPQ" -e "*"
85+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/patch.MPQ" -e "*"
86+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/patch-2.MPQ" -e "*"
87+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/patch-3.MPQ" -e "*"
88+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/$locale/backup-$locale.MPQ" -e "*"
89+
MPQExtractor -f -c -o "$OUT_DIR" "$WOW_DIR/Data/$locale/base-$locale.MPQ" -e "*"
90+
```
91+
6992
.. for every locale you are going to use:
7093
> \<localeCode>/DBFilesClient/
7194
> \<localeCode>/Interface/WorldMap/
@@ -87,16 +110,86 @@ Extract the following directories from the client archives into `setup/mpqdata/`
87110
> \<localeCode>/Interface/Glues/Loadingscreens/
88111
> \<localeCode>/Interface/Glues/Credits/
89112
90-
#### 5. Reencode the audio files
113+
### 5. Reencode the audio files
114+
91115
WAV-files need to be reencoded as `ogg/vorbis` and some MP3s may identify themselves as `application/octet-stream` instead of `audio/mpeg`.
92116
* [example for WIN](https://gist.github.com/Sarjuuk/d77b203f7b71d191509afddabad5fc9f)
93117
* [example for \*nix](https://gist.github.com/Sarjuuk/1f05ef2affe49a7e7ca0fad7b01c081d)
94118

95-
#### 6. Run the initial setup from the CLI
96-
`php aowow --setup`.
119+
### 6. Run the initial setup from the CLI
120+
121+
```sh
122+
php aowow --setup
123+
```
124+
97125
This should guide you through with minimal input required from your end, but will take some time though, especially compiling the zone-images. Use it to familiarize yourself with the other functions this setup has. Yes, I'm dead serious: *Go read the code!* It will help you understand how to configure AoWoW and keep it in sync with your world database.
98126
When you've created your admin account you are done.
99127

128+
## Run with Docker
129+
130+
Configure settings for first time:
131+
132+
1. Create environment settings files:
133+
```sh
134+
cp .env.aowow.dist .env.aowow
135+
cp .env.mysql.dist .env.mysql
136+
```
137+
Typically, `.env.mysql` is not required for production, because database server is hosted somewhere outside the docker.
138+
139+
> [!NOTE]
140+
> You don't need to change `config/config.php` file, it will be overwritten with a special file, which
141+
> takes required credentials from the environment. See `docker/aowow/src/config/config.php` for details.
142+
2. Edit `.env.*` files according to your environment, or leave as-is if environment is development.
143+
3. Optionally: setup path to mpqdata for `aowow` service in `compose.dev.yaml` file:
144+
Replace this part of code:
145+
```yaml
146+
# fixme optionally: change to directory with extracted mpq data
147+
- setup_aowow:/var/www/html/setup/mpqdata:rw
148+
# - /Users/md/Downloads/aowow-data/setup/mpqdata:/var/www/html/setup/mpqdata:ro
149+
```
150+
with this (change `/.../aowow/setup/mpqdata` to path with your actual data):
151+
```yaml
152+
- /.../aowow/setup/mpqdata:/var/www/html/setup/mpqdata:ro
153+
```
154+
155+
Run application:
156+
157+
```sh
158+
## for development:
159+
docker compose up -f compose.yaml -f compose.dev.yaml
160+
161+
## for production:
162+
docker compose up
163+
```
164+
165+
> [!NOTE]
166+
> First launch starts application initialization (database dumps download, loading dumps into database, downloading game data, extract media/info, etc ...)
167+
> It may take long time (up to 30 minutes and more). Please, be patient.
168+
>
169+
> If it's required to skip initialization at first launch, then set `SETUP_SKIP` option value to `1`.
170+
171+
Then web-application should be accessible at <http://172.28.0.10>.
172+
173+
> [!NOTE]
174+
> First launch may fail for some reason (e.g. fail to download data, slow network & healthcheck fail),
175+
> it's recommended to rebuild containers for initialization scripts invocation.
176+
177+
Rebuild only aowow service (don't wipe database data):
178+
179+
```sh
180+
docker container rm aowow-aowow-1
181+
docker volume rm aowow_setup_aowow
182+
docker compose -f compose.yaml -f compose.dev.yaml up --build
183+
```
184+
185+
Full rebuild (wipe all data):
186+
187+
```sh
188+
docker container rm aowow-mysql-1 aowow-aowow-1
189+
docker volume rm aowow_data_mysql aowow_data_aowow aowow_setup_aowow
190+
# docker volume rm aowow_setup_mysql # ... contains trinitycore SQL dumps, typically it's never required to be removed
191+
docker compose -f compose.yaml -f compose.dev.yaml up --build
192+
```
100193

101194
## Troubleshooting
102195

0 commit comments

Comments
 (0)