mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
Dockerize AzerothCore Database
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
||||
build*/
|
||||
var/*
|
||||
data/contrib/*
|
||||
data/doc/*
|
||||
modules/*
|
||||
conf/*
|
||||
!conf/*.dist
|
||||
18
docker/DB/Dockerfile
Normal file
18
docker/DB/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM alpine:latest as builder
|
||||
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
ADD apps /azerothcore/apps
|
||||
ADD conf /azerothcore/conf
|
||||
ADD data /azerothcore/data
|
||||
ADD deps /azerothcore/deps
|
||||
ADD acore.json /azerothcore/acore.json
|
||||
|
||||
RUN /azerothcore/apps/db_assembler/db_assembler.sh 1
|
||||
|
||||
|
||||
FROM mysql:5.7
|
||||
|
||||
COPY --from=builder /azerothcore/env/dist/sql /sql
|
||||
|
||||
ADD docker/DB/generate-databases.sh /docker-entrypoint-initdb.d
|
||||
83
docker/DB/README.md
Normal file
83
docker/DB/README.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# AzerothCore Dockerized Database
|
||||
|
||||
This provides a way to quickly launch one or more instances of a fully-ready AzerothCore database. It is particularly useful for testing/development purposes.
|
||||
|
||||
For example, with this you can quickly create a new, clean instance of the AzerothCore DB. Or create **multiple** instances each one available on a different **port** (that can be handy to test & compare things).
|
||||
|
||||
Instances (containers) can be easily set up and then destroyed, so you can always switch to a clean state after your experiments.
|
||||
|
||||
**NOTE**: you do **not** need to install any mysql-server manually in your system and if you already have it, the docker instances will **not** interfere with it.
|
||||
|
||||
|
||||
# Setup & usage instructions
|
||||
|
||||
### Requirements
|
||||
|
||||
The only requirement is [Docker](https://docs.docker.com/install/). You can install it on any operating system.
|
||||
|
||||
|
||||
## Building the container image
|
||||
|
||||
To build the container image you have to be in the **main folder** of your local AzerothCore sources directory.
|
||||
|
||||
If you don't have the AzerothCore sources, clone it using:
|
||||
|
||||
`git clone https://github.com/azerothcore/azerothcore-wotlk.git`
|
||||
|
||||
and cd into it `cd azerothcore-wotlk`.
|
||||
|
||||
You can build the image using:
|
||||
|
||||
`docker build -t azerothcore/database -f docker/DB/Dockerfile .`
|
||||
|
||||
**Note:** the version of your DB will be the one of your sources when you built the image. If you want to update it, just update your sources (`git pull`) and build the image again.
|
||||
|
||||
*For more information about the `docker build` command, check the [docker build doc](https://docs.docker.com/engine/reference/commandline/build/).*
|
||||
|
||||
|
||||
## How to launch a container
|
||||
|
||||
Run the following command to launch a container:
|
||||
|
||||
`docker run --name azt-db -p 127.0.0.1:3306:3306 -e MYSQL_ROOT_PASSWORD=password azerothcore/database`
|
||||
|
||||
Where:
|
||||
|
||||
`--name` is followed by a container name like `azt-db`. Put whatever name you like, each container should have an unique name.
|
||||
|
||||
`-p` (port) is followed by `IP_ADDRESS:EXTERNAL_PORT:INTERNAL_PORT`.
|
||||
|
||||
- INTERNAL_PORT **must** always be 3306.
|
||||
- EXTERNAL_PORT is the port that you will use to access the mysql-server that is running in your container
|
||||
|
||||
**NOTE**: You may want to use an external port different than 3306 in case you have already mysql-server installed in your system (or some other service that is using that port). So you can use for example port 9000 with `-p 127.0.0.1:9000:3306`
|
||||
|
||||
`docker run --name azt-db -p 9000:3306 -e MYSQL_ROOT_PASSWORD=password azerothcore/database`
|
||||
|
||||
`-e MYSQL_ROOT_PASSWORD=password` lets you change the default password for the `root` user.
|
||||
|
||||
`azerothcore/database` will be the name of your docker image.
|
||||
|
||||
You can optionally pass option `-d` to detach the container run from your terminal.
|
||||
|
||||
*For more information about the `docker run` command, check the [docker run doc](https://docs.docker.com/engine/reference/run/).*
|
||||
|
||||
## Launching more instances
|
||||
|
||||
You can easily run more instances. You just have to specify a different **name** and **port** for each.
|
||||
|
||||
Example: I want to launch three instances of the AzerothCore databases, each one listening respectively on port 9001, 9002 and 9003. I can do it with the following commands:
|
||||
|
||||
`docker run --name azt-db-1 -p 127.0.0.1:9001:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database`
|
||||
`docker run --name azt-db-2 -p 127.0.0.1:9002:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database`
|
||||
`docker run --name azt-db-3 -p 127.0.0.1:9003:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database`
|
||||
|
||||
You can use the `docker ps` command to check your running containers.
|
||||
|
||||
*For more information about the `docker ps` command, check the [docker ps doc](https://docs.docker.com/engine/reference/commandline/ps/).*
|
||||
|
||||
## Stopping / removing
|
||||
|
||||
You can stop a container using `docker stop name-of-the container`, for example `docker stop azt-db-1`.
|
||||
|
||||
You can then remove the container using `docker rm name-of-the container`, for example `docker rm azt-db-1`.
|
||||
41
docker/DB/generate-databases.sh
Normal file
41
docker/DB/generate-databases.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
# TODO: remove this line after we fully support mysql 5.7
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "SET GLOBAL sql_mode = '';"
|
||||
|
||||
|
||||
echo "Creating DBs..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE acore_auth"
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE acore_characters"
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE acore_world"
|
||||
|
||||
|
||||
echo "Importing auth base..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_auth < /sql/auth_base.sql
|
||||
|
||||
echo "Importing characters base..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_characters < /sql/characters_base.sql
|
||||
|
||||
echo "Importing world base..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_world < /sql/world_base.sql
|
||||
|
||||
|
||||
echo "Importing auth updates..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_auth < /sql/auth_update.sql
|
||||
|
||||
echo "Importing characters updates..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_characters < /sql/characters_update.sql
|
||||
|
||||
echo "Importing world updates..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_world < /sql/world_update.sql
|
||||
|
||||
|
||||
echo "Importing auth custom (if any)..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_auth < /sql/auth_custom.sql
|
||||
|
||||
echo "Importing characters custom (if any)..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_characters < /sql/characters_custom.sql
|
||||
|
||||
echo "Importing world custom (if any)..."
|
||||
mysql -u root -p$MYSQL_ROOT_PASSWORD acore_world < /sql/world_custom.sql
|
||||
|
||||
|
||||
echo "Done!"
|
||||
Reference in New Issue
Block a user