Skip to content

Commit d07564a

Browse files
committed
feature: add docker support
1 parent 707ffdc commit d07564a

File tree

17 files changed

+343
-1
lines changed

17 files changed

+343
-1
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.dist

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# initialization
2+
WORLD_DATABASE_DUMP_URL='https://github.com/TrinityCore/TrinityCore/releases/download/TDB335.21101/TDB_full_world_335.21101_2021_10_15.7z'
3+
AUTH_DATABASE_DUMP_URL='https://raw.githubusercontent.com/TrinityCore/TrinityCore/refs/heads/3.3.5/sql/base/auth_database.sql'
4+
CHARACTERS_DATABASE_DUMP_URL='https://raw.githubusercontent.com/TrinityCore/TrinityCore/refs/heads/3.3.5/sql/base/characters_database.sql'
5+
6+
EXTRACTED_DATA_ARCHIVE_URL='https://github.com/wowgaming/client-data/releases/download/v16/data.zip'
7+
MPQ_DATA_INTERFACE_URL='https://raw.githubusercontent.com/wowgaming/3.3.5-interface-files/refs/heads/main/GlobalStrings.lua'
8+
9+
# http
10+
HTTP_HOST=localhost
11+
HTTP_PORT=8117
12+
13+
# mysql
14+
MYSQL_HOST=mysql
15+
MYSQL_USER=root
16+
MYSQL_PWD=root
17+
MYSQL_DATABASE=aowow
18+
MYSQL_ROOT_PASSWORD=root
19+
20+
# aowow specific environment
21+
DB_AOWOW_HOST=mysql:3306
22+
DB_AOWOW_USER=root
23+
DB_AOWOW_PASS=root
24+
DB_AOWOW_DB=
25+
DB_AOWOW_PREFIX=aowow_
26+
27+
DB_WORLD_HOST=mysql:3306
28+
DB_WORLD_USER=root
29+
DB_WORLD_PASS=root
30+
DB_WORLD_DB=trinitycore_world
31+
DB_WORLD_PREFIX=
32+
33+
DB_AUTH_HOST=mysql:3306
34+
DB_AUTH_USER=root
35+
DB_AUTH_PASS=root
36+
DB_AUTH_DB=trinitycore_auth
37+
DB_AUTH_PREFIX=
38+
39+
DB_CHARACTERS_1_HOST=mysql:3306
40+
DB_CHARACTERS_1_USER=root
41+
DB_CHARACTERS_1_PASS=root
42+
DB_CHARACTERS_1_DB=trinitycore_characters
43+
DB_CHARACTERS_1_PREFIX=

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Environment
2+
.env
3+
14
# Git
25
*.orig
36

@@ -50,4 +53,3 @@
5053
/static/uploads/screenshots/*
5154
/static/uploads/signatures/*
5255
/static/uploads/temp/*
53-

.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|md|env|.dist)$">
7+
Deny from all
8+
</FilesMatch>
9+
510
<FilesMatch "^(index)\.php$">
611
Allow from all
712
</FilesMatch>

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 libfreetype-dev libjpeg62-turbo-dev libpng-dev libonig-dev libxml2-dev default-mysql-client libarchive-tools
7+
docker-php-ext-configure gd --with-freetype --with-jpeg
8+
docker-php-ext-install -j$(nproc) gd mbstring xml pdo_mysql mysqli
9+
EOF
10+
11+
RUN a2enmod rewrite
12+
13+
COPY ./docker/aowow/usr/local/bin/* /usr/local/bin
14+
15+
WORKDIR /var/www/html
16+
17+
CMD ["/usr/local/bin/entrypoint.sh"]
18+
19+
FROM php-base AS php-dev
20+
21+
# fixme: workaround to ignore TLS error on connection to mysql from aowow service: fix it correctly, instead ignoring
22+
COPY './docker/aowow/(home)/.my.cnf' /root
23+
24+
FROM php-base AS php-prod
25+
26+
COPY . .
27+
28+
FROM mariadb:12.0 AS mysql-dev
29+
30+
RUN apt update && apt-get install p7zip curl -y
31+
RUN mkdir -p /usr/local/share/mysql ; chown mysql:mysql /usr/local/share/mysql

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,40 @@ WAV-files need to be reencoded as `ogg/vorbis` and some MP3s may identify themse
9696
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.
9797
When you've created your admin account you are done.
9898

99+
## Install with Docker
100+
101+
```sh
102+
cp .env.dist .env #
103+
# ... then edit `.env` according to your environment, or leave as-is for development
104+
105+
# for development
106+
docker compose up -f compose.yaml -f compose.dev.yaml
107+
108+
# for production
109+
docker compose up
110+
```
111+
112+
> [!NOTE]
113+
> First launch may take long time (up to 30 minutes and more), application requires initialization
114+
> (download database dumps, load dumps into database, download game data, extract media/info, etc ...)
115+
> Please, be patient.
116+
117+
Then web-application should be accessible at <http://localhost:8117>
118+
119+
<details>
120+
<summary>Change web-server port:</summary>
121+
122+
Change `HTTP_PORT` environment variable in `.env` or override it on docker launch:
123+
124+
```sh
125+
HTTP_PORT=8042 docker compose up
126+
```
127+
128+
</details>
129+
130+
> [!NOTE]
131+
> First launch may fail for some reason (e.g. fail to download data, slow network & healthcheck fail),
132+
> it's recommended to rebuild containers for initialization scripts invocation.
99133
100134
## Troubleshooting
101135

compose.dev.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
services:
2+
mysql:
3+
build:
4+
dockerfile: Dockerfile
5+
target: mysql-dev
6+
context: .
7+
volumes:
8+
- ./docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro
9+
- setup_mysql:/usr/local/share/mysql:rw
10+
- data_aowow:/var/lib/mysql
11+
env_file:
12+
- path: .env
13+
required: true
14+
extra_hosts:
15+
# ... workaround to reuse services common environment variables, and make it working for service itself
16+
- 'mysql:127.0.0.1'
17+
healthcheck: # fixme on first launch
18+
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
19+
start_period: 1m
20+
start_interval: 10s
21+
interval: 1m
22+
timeout: 5s
23+
retries: 5
24+
25+
aowow:
26+
build:
27+
dockerfile: Dockerfile
28+
target: php-dev
29+
context: .
30+
volumes:
31+
- .:/var/www/html:ro
32+
- ./docker/aowow/src/config/config.php:/var/www/html/config/config.php:ro
33+
# - ./docker/aowow/(home)/.my.cnf:/root/.my.cnf:ro
34+
# - ./docker/aowow/usr/local/bin/entrypoint.sh:/usr/local/bin/entrypoint.sh:ro
35+
- ./docker/aowow/usr/local/bin/initialize.sh:/usr/local/bin/initialize.sh:ro
36+
- ./docker/aowow/usr/local/bin/initialize.d:/usr/local/bin/initialize.d:ro
37+
depends_on:
38+
mysql:
39+
condition: service_healthy
40+
41+
volumes:
42+
setup_mysql:
43+
# Contains database dump file. Required for aowow.
44+
# After setup is done, all data could be wiped, e.g. `find /usr/local/share/ -type f -delete`
45+
data_aowow:
46+
# Let database data live outside the container.

compose.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
aowow:
3+
build:
4+
dockerfile: Dockerfile
5+
target: php-prod
6+
context: .
7+
volumes:
8+
# ... assume all infrastructure setup is done,
9+
- setup_aowow:/var/www/html/setup/mpqdata:rw # `w` for assets download case
10+
ports:
11+
- "${HTTP_PORT:-80}:80"
12+
env_file:
13+
- path: .env
14+
required: true
15+
16+
volumes:
17+
setup_aowow:
18+
# Contains extracted files from MPQ archives (dbc files). Required for aowow setup on initialization.
19+
# After setup is done, all data could be wiped, e.g. `find /usr/local/share/ -type f -delete`
20+
data_aowow:
21+
# Application data. Reused between application deployments.

docker/aowow/(home)/.my.cnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[client]
2+
skip-ssl = true

docker/aowow/src/config/config.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
if (!defined('AOWOW_REVISION'))
3+
die('illegal access');
4+
5+
$AoWoWconf['aowow'] = array (
6+
'host' => getenv('DB_AOWOW_HOST') ?? 'localhost:3306',
7+
'user' => getenv('DB_AOWOW_USER') ?? 'root',
8+
'pass' => getenv('DB_AOWOW_PASS') ?? 'root',
9+
'db' => getenv('DB_AOWOW_DB') ??'aowow',
10+
'prefix' => getenv('DB_AOWOW_PREFIX') ?? 'aowow_',
11+
);
12+
$AoWoWconf['world'] = array (
13+
'host' => getenv('DB_WORLD_HOST') ?? 'localhost:3306',
14+
'user' => getenv('DB_WORLD_USER') ?? 'root',
15+
'pass' => getenv('DB_WORLD_PASS') ?? 'root',
16+
'db' => getenv('DB_WORLD_DB') ?? 'trinitycore_world',
17+
'prefix' => getenv('DB_WORLD_PREFIX') ?? '',
18+
);
19+
$AoWoWconf['auth'] = array (
20+
'host' => getenv('DB_AUTH_HOST') ?? 'localhost:3306',
21+
'user' => getenv('DB_AUTH_USER') ?? 'root',
22+
'pass' => getenv('DB_AUTH_PASS') ?? 'root',
23+
'db' => getenv('DB_AUTH_DB') ?? 'trinitycore_auth',
24+
'prefix' => getenv('DB_AUTH_PREFIX') ?? '',
25+
);
26+
$AoWoWconf['characters']['1'] = array (
27+
'host' => getenv('DB_CHARACTERS_1_HOST') ?? 'localhost:3306',
28+
'user' => getenv('DB_CHARACTERS_1_USER') ?? 'root',
29+
'pass' => getenv('DB_CHARACTERS_1_PASS') ?? 'root',
30+
'db' => getenv('DB_CHARACTERS_1_DB') ?? 'trinitycore_characters',
31+
'prefix' => getenv('DB_CHARACTERS_1_PREFIX') ?? '',
32+
);

0 commit comments

Comments
 (0)