diff --git a/.gitignore b/.gitignore index 726661ea7..542ce3f9b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ modules/* !modules/*.sh build*/ var/* +docker/authserver/authserver.conf +docker/worldserver/worldserver.conf +!docker/build !.gitkeep diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..3df55828b --- /dev/null +++ b/docker/README.md @@ -0,0 +1,36 @@ +# Run AzerothCore with Docker + +*This readme it's a summary of the AzerothCore docker features.* + +Docker. is a software that performs operating-system-level virtualization, allowing to wrap and launch applications inside containers. + +Thanks to Docker, you can quickly setup and run AzerothCore in any operating system. + +### Installation instructions + +To install AzerothCore using Docker, you have to: + +1) Install [Docker](https://docs.docker.com/install/). + +2) Launch one instance of the [AzerothCore Dockerized Database](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/database) + +3) Create an image of the [AzerothCore Dockerized Build](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/build) + +4) Launch one instance of the [AzerothCore Dockerized Authserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/authserver) + +5) Launch one instance of the [AzerothCore Dockerized Worldserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/worldserver) + + +### Memory usage + +The total amount of RAM when running all AzerothCore docker containers is **less than 2 GB**. + +![AzerothCore containers memory](https://user-images.githubusercontent.com/75517/51078287-10e65b80-16b3-11e9-807f-f59a5844dae5.png) + + +### Docker containers vs Virtual machines + +Usind Docker will have the same benefits as using virtual machines, but with much less overhead: + +![Docker containers vs Virtual machines](https://user-images.githubusercontent.com/75517/51078179-d4fec680-16b1-11e9-8ce6-87b5053f55dd.png) + diff --git a/docker/authserver/Dockerfile b/docker/authserver/Dockerfile new file mode 100644 index 000000000..c657ffde8 --- /dev/null +++ b/docker/authserver/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:bionic + +COPY --from=azerothcore/build:latest /azeroth-server /azeroth-server +COPY authserver.conf.dist /azeroth-server/etc/authserver.conf +COPY authserver.conf /azeroth-server/etc/authserver.conf + +RUN apt update && apt install -y libmysqlclient-dev libssl-dev libace-6.* libace-dev; \ + rm /azeroth-server/etc/worldserver.conf.dist; \ + mkdir /azeroth-server/logs; + +CMD ["/azeroth-server/bin/authserver"] diff --git a/docker/authserver/README.md b/docker/authserver/README.md new file mode 100644 index 000000000..8d938b565 --- /dev/null +++ b/docker/authserver/README.md @@ -0,0 +1,25 @@ +# AzerothCore Dockerized Authserver + +This provides a way to launch a container with the AzerothCore authserver running inside it. + +## Requirements + +- You need to have [Docker](https://docs.docker.com/install/) installed in your system. You can install it on any operating system. + +- You need to first build the [AzerothCore Build Image](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/build). + +- You have to copy the file `docker/authserver/authserver.conf.dist` and rename the copied file to `docker/authserver/authserver.conf`. Then open it and change the values where needed (you may need to change the DB port). + +## Building the container image + +To build the container image you have to be in the **main** folder of your local AzerothCore sources directory. + +```docker build -t azerothcore/authserver -f docker/authserver/Dockerfile docker/authserver/``` + +*For more information about the `docker build` command, check the [docker build doc](https://docs.docker.com/engine/reference/commandline/build/).* + +## Run the container + +```docker run --name azt-authserver --network host -it azerothcore/authserver``` + +*For more information about the `docker run` command, check the [docker run doc](https://docs.docker.com/engine/reference/run/).* diff --git a/docker/authserver/authserver.conf.dist b/docker/authserver/authserver.conf.dist new file mode 100644 index 000000000..8b40ec797 --- /dev/null +++ b/docker/authserver/authserver.conf.dist @@ -0,0 +1,13 @@ +############################################### +# AzerothCore Auth Server configuration file # +############################################### +[authserver] + +# Do not change this +LogsDir = "/azeroth-server/etc/logs" + +# Change this configuration accordingly with your setup +LoginDatabaseInfo = "127.0.0.1;3600;root;password;acore_auth" + +# Add more configuration overwrites +LogLevel = 3 diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile new file mode 100644 index 000000000..d282011ed --- /dev/null +++ b/docker/build/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:bionic + +RUN apt update && apt install -y git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev libace-6.* libace-dev + +ADD .git /azerothcore/.git +ADD deps /azerothcore/deps +ADD conf/config.cmake.dist /azerothcore/conf/config.cmake.dist +ADD src /azerothcore/src +ADD CMakeLists.txt /azerothcore/CMakeLists.txt + +RUN cd azerothcore; \ + mkdir build; \ + cd build; \ + cmake ../ -DCMAKE_INSTALL_PREFIX=/azeroth-server -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DTOOLS=0 -DSCRIPTS=1; \ + MTHREADS=`grep -c ^processor /proc/cpuinfo`; MTHREADS=$(($MTHREADS + 2)); \ + make -j $MTHREADS; \ + make install -j $MTHREADS; diff --git a/docker/build/README.md b/docker/build/README.md new file mode 100644 index 000000000..bd26c6aac --- /dev/null +++ b/docker/build/README.md @@ -0,0 +1,13 @@ +# AzerothCore Dockerized Build + +The AzerothCore Build Dockerfile is not meant to create containers, it is a stage that both the [authserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/authserver) and the [worldserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/worldserver) docker images will use. + +Note: every time you update your AzerothCore sources, you **must** build again this image and the authserver & worldserver images to get the new version on your docker containers. + +*For more information about Docker multi-stage builds, refer to the [docker multi-stage builds doc](https://docs.docker.com/develop/develop-images/multistage-build/).* + +# Usage + +To build the container image you have to be in the **main** folder of your local AzerothCore sources directory. + +```docker build -t azerothcore/build -f docker/build/Dockerfile . ``` diff --git a/docker/DB/Dockerfile b/docker/database/Dockerfile similarity index 82% rename from docker/DB/Dockerfile rename to docker/database/Dockerfile index 6c35792f2..e08f1cff6 100644 --- a/docker/DB/Dockerfile +++ b/docker/database/Dockerfile @@ -15,4 +15,4 @@ FROM mysql:5.7 COPY --from=builder /azerothcore/env/dist/sql /sql -ADD docker/DB/generate-databases.sh /docker-entrypoint-initdb.d +ADD docker/database/generate-databases.sh /docker-entrypoint-initdb.d diff --git a/docker/DB/README.md b/docker/database/README.md similarity index 91% rename from docker/DB/README.md rename to docker/database/README.md index 1a37a57be..ef0270fce 100644 --- a/docker/DB/README.md +++ b/docker/database/README.md @@ -28,7 +28,7 @@ and cd into it `cd azerothcore-wotlk`. You can build the image using: -`docker build -t azerothcore/database -f docker/DB/Dockerfile .` +`docker build -t azerothcore/database -f docker/database/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. @@ -58,8 +58,14 @@ Where: `azerothcore/database` will be the name of your docker image. +When the container is ready, you will see a message similar to: + +> Version: '5.7.24' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) + You can optionally pass option `-d` to detach the container run from your terminal. +You can optionally pass option `-it` to run the container as an interactive process (so you can kill it with ctrl+c). + *For more information about the `docker run` command, check the [docker run doc](https://docs.docker.com/engine/reference/run/).* ## Launching more instances diff --git a/docker/DB/generate-databases.sh b/docker/database/generate-databases.sh similarity index 100% rename from docker/DB/generate-databases.sh rename to docker/database/generate-databases.sh diff --git a/docker/worldserver/Dockerfile b/docker/worldserver/Dockerfile new file mode 100644 index 000000000..32f490428 --- /dev/null +++ b/docker/worldserver/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:bionic + +COPY --from=azerothcore/build:latest /azeroth-server /azeroth-server +COPY worldserver.conf.dist /azeroth-server/etc/worldserver.conf +COPY worldserver.conf /azeroth-server/etc/worldserver.conf + +RUN apt update && apt install -y libmysqlclient-dev libssl-dev libace-6.* libace-dev libreadline-dev; \ + rm /azeroth-server/etc/authserver.conf.dist; \ + mkdir /azeroth-server/logs; + +CMD ["/azeroth-server/bin/worldserver"] diff --git a/docker/worldserver/README.md b/docker/worldserver/README.md new file mode 100644 index 000000000..626803571 --- /dev/null +++ b/docker/worldserver/README.md @@ -0,0 +1,33 @@ +# AzerothCore Dockerized Worldserver + +This provides a way to launch a container with the AzerothCore authserver running inside it. + +## Requirements + +- You need to have [Docker](https://docs.docker.com/install/) installed in your system. You can install it on any operating system. + +- You need to first build the [AzerothCore Build Image](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/build). + +- You have to copy the file `docker/worldserver/worldserver.conf.dist` and rename the copied file to `docker/worldserver/worldserver.conf`. Then open it and change the values where needed (you may need to change the DB port). + +- You need to have the **data files** somewhere in your system. If you don't have them yet, check the step ["Download the data files" from the installation guide](https://github.com/AzerothCore/azerothcore-wotlk/wiki/Installation#5-download-the-data-files). + +## Building the container image + +To build the container image you have to be in the **main** folder of your local AzerothCore sources directory. + +```docker build -t azerothcore/worldserver -f docker/worldserver/Dockerfile docker/worldserver``` + +*For more information about the `docker build` command, check the [docker build doc](https://docs.docker.com/engine/reference/commandline/build/).* + +## Run the container + +Replace `/path/to/your/data` with the path of where your data folder is. + +```docker run --name azt-worldserver --mount type=bind,source=/path/to/your/data,target=/azeroth-server/data --network host -it azerothcore/worldserver` + +*For more information about the `docker run` command, check the [docker run doc](https://docs.docker.com/engine/reference/run/).* + + + +`` diff --git a/docker/worldserver/worldserver.conf.dist b/docker/worldserver/worldserver.conf.dist new file mode 100644 index 000000000..470975923 --- /dev/null +++ b/docker/worldserver/worldserver.conf.dist @@ -0,0 +1,16 @@ +################################################ +# AzerothCore World Server configuration file # +################################################ +[worldserver] + +# Do not change those +LogsDir = "/azeroth-server/etc/logs" +DataDir = "/azeroth-server/data" + +# Change those configuration accordingly with your setup +LoginDatabaseInfo = "127.0.0.1;3600;root;password;acore_auth" +WorldDatabaseInfo = "127.0.0.1;3600;root;password;acore_world" +CharacterDatabaseInfo = "127.0.0.1;3600;root;password;acore_characters" + +# Add more configuration overwrites +LogLevel = 2