diff --git a/.dockerignore b/.dockerignore index 36e6731b1..ba817a55c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,6 @@ data/doc/* modules/* conf/* !conf/*.dist +docker/worldserver/data/* +.idea +cmake-build-debug/* diff --git a/.env.dist b/.env.dist new file mode 100644 index 000000000..8114959e2 --- /dev/null +++ b/.env.dist @@ -0,0 +1,11 @@ +WORLDSERVER_DATA="./docker/worldserver/data" +WORLDSERVER_ETC="./docker/worldserver/etc" +WORLDSERVER_LOGS="./docker/worldserver/logs" + +AUTHSERVER_ETC="./docker/authserver/etc" +AUTHSERVER_LOGS="./docker/authserver/logs" + +WORLD_EXTERNAL_PORT=8085 +AUTH_EXTERNAL_PORT=3724 +DB_EXTERNAL_PORT=3306 +DB_ROOT_PASSWORD=password diff --git a/.gitignore b/.gitignore index d6d60c197..36b12a76d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,9 @@ docker/authserver/etc/authserver.conf docker/worldserver/etc/worldserver.conf docker/authserver/logs/ docker/worldserver/logs/ +docker/worldserver/data/ !docker/build +.env !.gitkeep diff --git a/bin/acore-docker-build b/bin/acore-docker-build new file mode 100644 index 000000000..a13c92ebf --- /dev/null +++ b/bin/acore-docker-build @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker build -t azerothcore/build -f docker/build/Dockerfile . diff --git a/bin/acore-docker-generate-etc b/bin/acore-docker-generate-etc new file mode 100644 index 000000000..40c8be689 --- /dev/null +++ b/bin/acore-docker-generate-etc @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +cp docker/worldserver/etc/worldserver.conf.dockerdist docker/worldserver/etc/worldserver.conf +cp docker/authserver/etc/authserver.conf.dockerdist docker/authserver/etc/authserver.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..49b53fe06 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,61 @@ +version: '3.2' + +services: + + ac-database: + image: azerothcore/database + build: + context: . + dockerfile: ./docker/database/Dockerfile + networks: + - ac-network + ports: + - ${DB_EXTERNAL_PORT:-3306}:3306 + environment: + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-password} + + ac-worldserver: + stdin_open: true + tty: true + image: azerothcore/worldserver + build: + context: ./docker/worldserver + dockerfile: Dockerfile + networks: + - ac-network + ports: + - ${WORLD_EXTERNAL_PORT:-8085}:8085 + volumes: + - type: bind + source: ${WORLDSERVER_ETC:-./docker/worldserver/etc} + target: /azeroth-server/etc + - type: bind + source: ${WORLDSERVER_LOGS:-./docker/worldserver/logs} + target: /azeroth-server/logs + - type: bind + source: ${WORLDSERVER_DATA:-./docker/worldserver/data} + target: /azeroth-server/data + depends_on: + - ac-database + + ac-authserver: + image: azerothcore/authserver + build: + context: ./docker/authserver + dockerfile: Dockerfile + networks: + - ac-network + ports: + - ${AUTH_EXTERNAL_PORT:-3724}:3724 + volumes: + - type: bind + source: ${AUTHSERVER_ETC:-./docker/authserver/etc} + target: /azeroth-server/etc + - type: bind + source: ${AUTHSERVER_LOGS:-./docker/authserver/logs} + target: /azeroth-server/logs + depends_on: + - ac-database + +networks: + ac-network: diff --git a/docker/README.md b/docker/README.md index 2f70179c8..d642a16ea 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,23 +6,29 @@ Docker. is a software that performs operating-system-level virtualization, allow Thanks to Docker, you can quickly setup and run AzerothCore in any operating system. -The **only** requirement is having Docker installed into your system. Forget about installing mysql, visual studio, cmake, etc... +The **only** requirement is having [Docker](https://docs.docker.com/install/) installed into your system. Forget about installing mysql, visual studio, cmake, etc... ### Installation instructions -To install AzerothCore using Docker, you have to follow these steps (**respecting the order**): +To install and AzerothCore using Docker, you have two options -1) Install [Docker](https://docs.docker.com/install/). +#### Option A. Using Docker Compose (very easy - recommended) -2) Create a Docker Network: `docker network create ac-network`. All your docker containers will use it to communicate to each other. +- Check the [Install with Docker](https://github.com/azerothcore/azerothcore-wotlk/wiki/install-with-Docker) guide. -3) Launch one instance of the [AzerothCore Dockerized Database](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/database) +#### Option B. Build and start each container manually (longer - not recommended) -4) Create an image of the [AzerothCore Dockerized Build](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/build) +You have to follow these steps (**respecting the order**): -5) Launch one instance of the [AzerothCore Dockerized Authserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/authserver) +1) Create a Docker Network: `docker network create ac-network`. All your docker containers will use it to communicate to each other. -6) Launch one instance of the [AzerothCore Dockerized Worldserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/worldserver) +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 diff --git a/docker/authserver/README.md b/docker/authserver/README.md index 44f1637e1..3353e8745 100644 --- a/docker/authserver/README.md +++ b/docker/authserver/README.md @@ -1,6 +1,8 @@ # AzerothCore Dockerized Authserver -This provides a way to launch a container with the AzerothCore authserver running inside it. +This provides a way to manually build and launch a container with the AzerothCore authserver running inside it. + +If you just want to install the whole AzerothCore quickly using Docker Compose, we recommend [this guide](https://github.com/azerothcore/azerothcore-wotlk/wiki/install-with-Docker). ## Requirements @@ -16,14 +18,16 @@ This provides a way to launch a container with the AzerothCore authserver runnin 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/``` +``` +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 ac-auth-container \ +docker run --name ac-authserver \ --mount type=bind,source="$(pwd)"/docker/authserver/etc/,target=/azeroth-server/etc \ --mount type=bind,source="$(pwd)"/docker/authserver/logs/,target=/azeroth-server/logs \ -p 127.0.0.1:3724:3724 \ diff --git a/docker/authserver/etc/authserver.conf.dockerdist b/docker/authserver/etc/authserver.conf.dockerdist index a2b6d9a3f..bebf9cf15 100644 --- a/docker/authserver/etc/authserver.conf.dockerdist +++ b/docker/authserver/etc/authserver.conf.dockerdist @@ -10,7 +10,7 @@ LogsDir = "/azeroth-server/logs" # will reflect on your host directory: docker/w # The format is "hostname;port;username;password;database": # - docker containers must be on the same docker network to be able to communicate # - the DB hostname will be the name of the database docker container -LoginDatabaseInfo = "ac-db-container;3306;root;password;acore_auth" +LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth" # Add more configuration overwrites by copying settings from from authserver.conf.dist LogLevel = 3 diff --git a/docker/build/README.md b/docker/build/README.md index bd26c6aac..cf5b113ab 100644 --- a/docker/build/README.md +++ b/docker/build/README.md @@ -10,4 +10,6 @@ Note: every time you update your AzerothCore sources, you **must** build again t 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 . ``` +``` +docker build -t azerothcore/build -f docker/build/Dockerfile . +``` diff --git a/docker/database/README.md b/docker/database/README.md index 8468db8a5..3db2de48c 100644 --- a/docker/database/README.md +++ b/docker/database/README.md @@ -9,6 +9,9 @@ Instances (containers) can be easily set up and then destroyed, so you can alway **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. +If you just want to install the whole AzerothCore quickly using Docker Compose, we recommend following [this guide instead](https://github.com/azerothcore/azerothcore-wotlk/wiki/install-with-Docker). + + # Setup & usage instructions ### Requirements @@ -28,7 +31,9 @@ and cd into it `cd azerothcore-wotlk`. You can build the image using: -`docker build -t azerothcore/database -f docker/database/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. @@ -39,7 +44,8 @@ You can build the image using: Run the following command to launch a container: -```docker run --name ac-db-container \ +``` +docker run --name ac-database \ -p 127.0.0.1:3306:3306 \ -e MYSQL_ROOT_PASSWORD=password \ --network ac-network \ @@ -48,7 +54,7 @@ Run the following command to launch a container: Where: -`--name` is followed by a container name like `ac-db-container`. Put whatever name you like, each container should have an unique name. +`--name` is followed by a container name like `ac-database`. Put whatever name you like, each container should have an unique name. `-p` (port) is followed by `IP_ADDRESS:EXTERNAL_PORT:INTERNAL_PORT`. @@ -59,7 +65,7 @@ Where: **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 ac-db-container -p 9000:3306 -e MYSQL_ROOT_PASSWORD=password azerothcore/database` +`docker run --name ac-database -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. @@ -81,9 +87,9 @@ You can easily run more instances. You just have to specify a different **name** 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 ac-db-container-1 -p 127.0.0.1:9001:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database` -`docker run --name ac-db-container-2 -p 127.0.0.1:9002:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database` -`docker run --name ac-db-container-3 -p 127.0.0.1:9003:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database` +`docker run --name ac-database-1 -p 127.0.0.1:9001:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database` +`docker run --name ac-database-2 -p 127.0.0.1:9002:3306 -e MYSQL_ROOT_PASSWORD=password -d azerothcore/database` +`docker run --name ac-database-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. @@ -91,6 +97,6 @@ You can use the `docker ps` command to check your running containers. ## Stopping / removing -You can stop a container using `docker stop name-of-the container`, for example `docker stop ac-db-container-1`. +You can stop a container using `docker stop name-of-the container`, for example `docker stop ac-database-1`. -You can then remove the container using `docker rm name-of-the container`, for example `docker rm ac-db-container-1`. +You can then remove the container using `docker rm name-of-the container`, for example `docker rm ac-database-1`. diff --git a/docker/worldserver/README.md b/docker/worldserver/README.md index 4161ff554..23c63e4ec 100644 --- a/docker/worldserver/README.md +++ b/docker/worldserver/README.md @@ -1,6 +1,8 @@ # AzerothCore Dockerized Worldserver -This provides a way to launch a container with the AzerothCore authserver running inside it. +This provides a way to build and launch a container with the AzerothCore authserver running inside it. + +If you just want to install the whole AzerothCore quickly using Docker Compose, we recommend following [this guide instead](https://github.com/azerothcore/azerothcore-wotlk/wiki/install-with-Docker). ## Requirements @@ -27,7 +29,7 @@ To build the container image you have to be in the **main** folder of your local Replace `/path/to/your/data` with the path of where your data folder is. ``` -docker run --name ac-world-container \ +docker run --name ac-worldserver \ --mount type=bind,source=/path/to/your/data,target=/azeroth-server/data \ --mount type=bind,source="$(pwd)"/docker/worldserver/etc/,target=/azeroth-server/etc \ --mount type=bind,source="$(pwd)"/docker/worldserver/logs/,target=/azeroth-server/logs \ diff --git a/docker/worldserver/data/.gitkeep b/docker/worldserver/data/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/docker/worldserver/etc/worldserver.conf.dockerdist b/docker/worldserver/etc/worldserver.conf.dockerdist index a746aa545..9f67198bf 100644 --- a/docker/worldserver/etc/worldserver.conf.dockerdist +++ b/docker/worldserver/etc/worldserver.conf.dockerdist @@ -11,9 +11,9 @@ DataDir = "/azeroth-server/data" # The format is "hostname;port;username;password;database": # - docker containers must be on the same docker network to be able to communicate # - the DB hostname will be the name of the database docker container -LoginDatabaseInfo = "ac-db-container;3306;root;password;acore_auth" -WorldDatabaseInfo = "ac-db-container;3306;root;password;acore_world" -CharacterDatabaseInfo = "ac-db-container;3306;root;password;acore_characters" +LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth" +WorldDatabaseInfo = "ac-database;3306;root;password;acore_world" +CharacterDatabaseInfo = "ac-database;3306;root;password;acore_characters" # Add more configuration overwrites by copying settings from worldserver.conf.dist LogLevel = 2