Files
azerothcore-wotlk/apps/docker/Dockerfile
Yehonal 380f406248 Feat(Docker/bash): docker-compose system rework (#4488)
## ⚠️ATTENTION! ⚠️ Upgrading procedure:

**Database:** After this PR will be merged you need to backup your DB first (you can use the db-assembler or any mysql client to generate the dump) and restore it after.  The reason is that we use now docker named volumes instead of binded ones to improve performance.

**Conf & client data**: if you use the default configuration, both the etc and the data folder are now available inside the **/env/docker**. 

Finally, you can cleanup the /docker folder previously used by our system.

## Changes Proposed:

This PR will implement the [devcontainer ](https://code.visualstudio.com/docs/remote/containers) feature for VSCode. Allowing us to develop and debug directly within the container in the same way on all OSes.

* Implemented support for vscode dev-container feature by remote-extension suite
* Docker performance optimizations for MacOS and non-linux hosts
* Bash system improvements
* Implemented first command using Deno runtime environment (typescript) and [commander.js]
* Implemented wait mechanism for db_assembler
* Implemented db migration command
* possibility to run the authserver and worldserver with GDB using the integrated simple-restarter
* Implemented docker multi-stage mechanism to use one single Dockerfile for all the services
* client-data downloader now creates a placeholder to avoid downloading the same version of data files multiple times
* deployment of pre-compiled docker images on [docker hub](https://hub.docker.com/u/acore), you can test them [here](https://github.com/azerothcore/acore-docker)
2021-04-22 09:57:05 +02:00

129 lines
3.7 KiB
Docker

#================================================================
#
# DEV: Stage used for the development environment
# and the locally built services
#
#=================================================================
FROM ubuntu:20.04 as dev
ARG USER_ID=1000
ARG GROUP_ID=1000
LABEL description="AC Worldserver Debug Container for use with Visual Studio"
# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ENV DOCKER=1
# set timezone environment variable
ENV TZ=Etc/UTC
# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive
# install essentials
RUN apt-get update && apt-get install -y gdb gdbserver git dos2unix lsb-core sudo curl unzip
# copy everything so we can work directly within the container
# using tools such as vscode dev-container
COPY . /azerothcore
# install the required dependencies to run the worldserver
RUN /azerothcore/acore.sh install-deps
# change timezone in container
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
# Create a non-root user
RUN addgroup --gid $GROUP_ID acore && \
adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID acore && \
passwd -d acore && \
echo 'acore ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
RUN mkdir -p /azerothcore
# Correct permissions for non-root operations
RUN chown -R acore:acore \
/run \
/home/acore \
/opt/ \
/azerothcore
USER acore
WORKDIR /azerothcore
#================================================================
#
# BUILD STAGE: to prepare binaries for the production services
#
#=================================================================
FROM dev as build
RUN bash acore.sh compiler build
#================================================================
#
# SERVICE BASE: prepare the OS for the production-ready services
#
#=================================================================
FROM ubuntu:20.04 as servicebase
# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# set timezone environment variable
ENV TZ=Etc/UTC
# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive
COPY --from=build /azerothcore/env /azerothcore/env
# copy the sources from the host machine
COPY apps /azerothcore/apps
COPY bin /azerothcore/bin
COPY conf /azerothcore/conf
COPY data /azerothcore/data
COPY deps /azerothcore/deps
COPY acore.json /azerothcore/acore.json
COPY acore.sh /azerothcore/acore.sh
# install the required dependencies to run the authserver
RUN apt-get update && apt-get install -y gdb gdbserver net-tools tzdata libmysqlclient-dev libace-dev mysql-client curl unzip;
# change timezone in container
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
WORKDIR /azerothcore/
RUN cp -n "/azerothcore/env/docker/etc/worldserver.conf.dockerdist" "/azerothcore/env/dist/etc/worldserver.conf"
RUN cp -n "/azerothcore/env/docker/etc/authserver.conf.dockerdist" "/azerothcore/env/dist/etc/authserver.conf"
#================================================================
#
# AUTH SERVICE: create a ready-to-use authserver image
#
#=================================================================
FROM servicebase as authserver
CMD ./acore.sh run-authserver
#================================================================
#
# WORLD SERVICE: create a ready-to-use worldserver image
#
#=================================================================
FROM servicebase as worldserver
ENV DATAPATH=/azerothcore/env/dist/data
RUN /azerothcore/acore.sh client-data
CMD ./acore.sh run-worldserver