feat(docker): add cache for faster rebuild (#1507)

- Closes #1502
This commit is contained in:
Francesco Borzì
2019-02-23 17:34:56 +01:00
committed by GitHub
parent 53098cd1e0
commit e659ca5fe9
14 changed files with 64 additions and 21 deletions

3
.gitignore vendored
View File

@@ -12,6 +12,9 @@ modules/*
!modules/*.sh
build*/
var/*
docker/build/cache
docker/authserver/bin
docker/worldserver/bin
docker/authserver/etc/authserver.conf
docker/worldserver/etc/worldserver.conf
docker/authserver/logs/

View File

@@ -1,3 +1,9 @@
#!/usr/bin/env bash
docker build -t azerothcore/build -f docker/build/Dockerfile .
docker build -t acbuild -f docker/build/Dockerfile .
docker run \
-v /$(pwd)/docker/build/cache:/azerothcore/build \
-v /$(pwd)/docker/worldserver/bin:/binworldserver \
-v /$(pwd)/docker/authserver/bin:/binauthserver \
acbuild

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
sudo rm -rf ./docker/build/cache/CMakeFiles
sudo rm -rf ./docker/build/cache/deps
sudo rm -rf ./docker/build/cache/src
sudo rm ./docker/build/cache/*.cmake
sudo rm ./docker/build/cache/*.txt
sudo rm ./docker/build/cache/*.h
sudo rm ./docker/build/cache/*.cpp
sudo rm ./docker/build/cache/Makefile

View File

@@ -26,6 +26,9 @@ services:
ports:
- ${WORLD_EXTERNAL_PORT:-8085}:8085
volumes:
- type: bind
source: ./docker/worldserver/bin
target: /azeroth-server/bin
- type: bind
source: ${WORLDSERVER_ETC:-./docker/worldserver/etc}
target: /azeroth-server/etc
@@ -48,6 +51,9 @@ services:
ports:
- ${AUTH_EXTERNAL_PORT:-3724}:3724
volumes:
- type: bind
source: ./docker/authserver/bin
target: /azeroth-server/bin
- type: bind
source: ${AUTHSERVER_ETC:-./docker/authserver/etc}
target: /azeroth-server/etc

View File

@@ -24,11 +24,11 @@ You have to follow these steps (**respecting the order**):
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)
3) Build AzerothCore using [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)
5) Launch one instance of the [AzerothCore Dockerized Worldserver](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/worldserver)
### Memory usage

View File

@@ -2,6 +2,4 @@ FROM ubuntu:bionic
RUN apt update && apt install -y libmysqlclient-dev libssl-dev libace-6.* libace-dev;
COPY --from=azerothcore/build:latest /azeroth-server/bin /azeroth-server/bin
CMD ["/azeroth-server/bin/authserver"]

View File

@@ -28,6 +28,7 @@ docker build -t azerothcore/authserver -f docker/authserver/Dockerfile docker/au
```
docker run --name ac-authserver \
--mount type=bind,source="$(pwd)"/docker/authserver/bin/,target=/azeroth-server/bin \
--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 \

View File

View File

@@ -8,10 +8,10 @@ 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;
ENTRYPOINT cd azerothcore/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 && \
cp /azeroth-server/bin/worldserver /binworldserver && \
cp /azeroth-server/bin/authserver /binauthserver

View File

@@ -1,15 +1,35 @@
# 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.
The AzerothCore Build Dockerfile will create a container that will run the AC build.
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.
When this container runs, it will compile AC and generate:
*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/).*
- the build cache in the `docker/build/cache` directory
- the `worldserver` executable file in `docker/worldserver/bin`
- the `authserver` executable file in `docker/authserver/bin`
# Usage
The executable files will be used by 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 containers.
To build the container image you have to be in the **main** folder of your local AzerothCore sources directory.
Note: every time you update your AzerothCore sources, you **must** run again the build container and restart your `worldserver` and `authserver` containers.
## Usage
To build the container image you have to be in the **main** folder of your local AzerothCore sources directory and run:
```
docker build -t azerothcore/build -f docker/build/Dockerfile .
docker build -t acbuild -f docker/build/Dockerfile .
```
Then you can launch the container to rebuild AC using:
```
docker run \
-v /$(pwd)/docker/build/cache:/azerothcore/build \
-v /$(pwd)/docker/worldserver/bin:/binworldserver \
-v /$(pwd)/docker/authserver/bin:/binauthserver \
acbuild
```
### Clearing the cache
To clear the build cache, delete all files contained under the `docker/build/cache` directory.

0
docker/build/cache/.gitkeep vendored Normal file
View File

View File

@@ -2,6 +2,4 @@ FROM ubuntu:bionic
RUN apt update && apt install -y libmysqlclient-dev libssl-dev libace-6.* libace-dev libreadline-dev;
COPY --from=azerothcore/build:latest /azeroth-server/bin /azeroth-server/bin
CMD ["/azeroth-server/bin/worldserver"]

View File

@@ -8,7 +8,7 @@ If you just want to install the whole AzerothCore quickly using Docker Compose,
- 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 need to first build AzerothCore using the [AzerothCore Dockerized Build](https://github.com/azerothcore/azerothcore-wotlk/tree/master/docker/build).
- If you haven't created a docker network yet, create it by simply using `docker network create ac-network`.
@@ -31,6 +31,7 @@ Replace `/path/to/your/data` with the path of where your data folder is.
```
docker run --name ac-worldserver \
--mount type=bind,source=/path/to/your/data,target=/azeroth-server/data \
--mount type=bind,source="$(pwd)"/docker/worldserver/bin/,target=/azeroth-server/bin \
--mount type=bind,source="$(pwd)"/docker/worldserver/etc/,target=/azeroth-server/etc \
--mount type=bind,source="$(pwd)"/docker/worldserver/logs/,target=/azeroth-server/logs \
-p 127.0.0.1:8085:8085 \

View File