Welcome to AC Web.
Results 1 to 3 of 3
  1. #1

    [Adv. Guide] Using Docker for Servers and Repacks [Linux/Mac]


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    This is a guide on using docker for running your WoW server as well as a method by which Linux and Mac repacks can be created and distributed. The guide assumes that you have some familiarity with Linux and have at least gone through the docker introduction. The guide will not cover docker usage itself except insofar as it applies to the guide. Expect docker commands and features to be used with little or no introduction.

    For the above reasons, this is considered an advanced guide.


    Download the base files here: https://copy.com/H8I2dJ8VLija


    What is Docker?
    Docker (https://www.docker.io/) is an open-source engine that allows any application to be packed, shipped, and run as a lightweight container that can be run on several platforms[*1].

    This then allows creation of one (or more) containers for a server and have it run with little to no change on mulitple platforms. So if making a repack, we need not be concerned that a user is running ArchLinux, Fedora, Ubuntu or even a Mac. The server will run on their system via docker.

    If making a public server, having things in one or more containers allows easier managment of the server as well as easing the server update path and adds an extra layer of security. Testing custom changes is made easier and the containers can help in minimizing downtime.


    [*1] At the time writing, Docker runs on 64-bit Linux systems with kernel version 3.8 or later and can be provisioned on Mac and Windows OSes. It can also be provisioned on Amazon EC2, Rackspace, Google Cloud and others.


    Docker-izing a Server
    There are several ways that a server can be packaged in containers and each comes with its own set of decisions. What I'll show here is merely one way this can be done of course.

    My goal was essentially two-fold. First to create a design that is flexible enough that components can be added or changed relatively easily, and second can support either repacks or running a server.

    I chose Trinity for my tests as I am familiar with it, but any server core could be used.

    With this in mind, the design uses multiple containers that can interact with each other and uses host folders mounted inside the containers for data persistance and easy access to configuration files. Mapped folders also allows us to have the server exectuables outside of the containers simplifying server updates.

    So first, a folder structure was designed so that all the required components of the server can reside here. This keeps all information that the containers will require access to in one location while at the same time, for repacks, this could then be distributed in a Zip or other compressed form.

    The folder structure I decided on was as follows:
    Code:
    + server
       + core
       |   + bin        (server executables)
       |   + conf       (config files for autheserver and worldserver)
       |   + data       (dbc, maps, mmaps, vmaps)
       |   + logs       
       |      + auth    (authserver logs)
       |      + realm   (worlserver logs)
       + mysql
           + conf       (my.cnf and other mysql configuration files)
           + data       (MySQL puts database files here)
    For the containers themselves, I split things as follows:
    • Database container
      Runs the MySQL database. Maps the server/mysql/conf and data folders.
    • Server Runner
      Runs a server component. The same container image can be used for the authentication server and world server(s). Maps the required folders as needed.
    • Compiler
      Since the containers will be running their own enclosed environment (I chose a base Ubuntu 13.04 for this), I compatible container will be used in order to compile and install the server source as needed. This container only needs to run when compiling and need not be distributed in repacks or part of the server itself.


    Finally, a couple of bash scripts will be needed to start things.

    Folder structure and scripts are available in the downloadable Zip linked above (see the server folder in the Zip file).


    The Containers
    For all the containers, I chose to use an environment based on Ubuntu 13.04 (raring). This made it easy to install any packages needed.

    For the database container I chose to use MariaDB 10. Unfortunately, MariaDB doesn't have an install for 13.04 so I used the one for 12.10 (quantal) instead.

    The database container is probably the hardest one to get right so a bit of trickery is needed during the creation of the container image so that the database is created in the correct folder. This is taken care of by the container's startup script.

    The server runner container uses only non-development versions of the needed packages in order to keep the container overhead to a minimum. Since this container merely runs scripts and executables from a mounted host volume, there isn't a need to include them in the container itself.

    Since the server runner container will be linked to the database container in order for it to use the database, a bit of scripting is needed in order to find the IP address of the linked database container. This is taken care of by the scripts found in the core folder.

    The server runner container is designed to be run as a user called server with a uid of 1000 (which is typically the first user on most Linux systems), this then should allow a nice mapping between the host and the container for file permissions.

    The compiler container has GCC and all needed development packages installed since this container will be used for compiling the source. This way, we know that the compiled core will run properly in the server runner container.

    For compiling, the container is designed to be run in interactive mode and so merely places the user at a bash prompt. From there, the usual compiling commands can be done. Including pulling the source code. One thing to remember though is that inside the compiler container you are running as root so you may need to change permissions on some files when copying/moving them into appropriate folders.


    Setting Up a Server/Repack
    To setup a server or repack, first create a folder somewhere on your machine and decompress the base files there (if you don't already have them). then create a second folder somewhere to use as the location the server/repack will reside (you can also use the server folder created from the Zip).

    Copy the contents of the server folder from the base files into your server/repack folder (skip this step if using the server folder created from the zip since everything you need is already there).

    Build the docker container images (if you haven't done so before) by going into the compile, mariadb and runserver folders (do this once for each) and build the docker container image with
    Code:
    docker build imagename .
    where imagename is the name you want to save this container image as. The Dockerfile in each folder shows the command to use for building each docker image.

    The above will then download any base images it needs (if not already downloaded) and will then install and setup the container.

    Once built, go to the folder where your server/repack will go and manually start the mariadb image (see the mariadb Dockerfile for how to start it). However, I recommend starting it in interactive mode so that you can see the messages while it generates the database. To do this, change the -itd in the run command to -it. If your machine already has a MySQL server running on port 3306, change the start command to remap the host side port used. For example, to change the host side port to 3307, change the the -p parameter to read -p 3307:3306. To disallow external network connections to the database server, you can ensure the port mapping is local only by again adding the interface IP to the -p parameter. For example, to map to the host's 127.0.0.1 interface (localhost) only, use -p 127.0.0.1:3306:3306. Press ^P^Q to detach from the container without stopping it.

    This first run of the database container will create and initialize the MariaDB database files. Note that it does not add in the TrinityDB, it merely creates a blank database and sets a default root account with password root. Log into the database using your MySQL editor of choice and install your database as you would normally. You can add/modify MySQL accounts as normal, but be aware that localhost and/or 127.0.0.1 refers to the the virtual network interface of the container, not the one on your machine.

    To compile the Trinity source, go the the folder where you want your server/repack and create a folder called source in here, place the source you want to compile. See the README.txt for the compile Dockerfile from the Zip for details on compiling and installing the server itself. Note that the Zip file provides already existing basic authserver.conf and worldserver.conf files. These have the database address set to dbaddress which is a special host alias setup at container start. Also the data and log directories are set so that they point to this setup's folder structure. It is recommended that any custom configurations keep these as is.

    Once the server has been compiled and installed (and optionally the DBC and maps are extracted), the compiler container can be stopped and removed, as well as the source folder itself.

    The authserver and worldserver can now be started for the first time to check if everything is fine. Again, when starting it up for the first time, it is recommended that it be done in interactive mode so that you can see what is going on. However, since the servers will log their output, it is not strictly necessary. Again, to detach from a running container, press ^P^Q.

    To reattach to a running container, use
    Code:
    docker attach CONTAINER
    where CONTAINER is the name or ID of the container you want to attach to.

    To see a list of active containers, use
    Code:
    docker ps -a
    Note that a container will stay active even after it has stopped. This will prevent you from starting another container with the same name. To remove a container, use
    Code:
    docker rm CONTAINER
    To see a list of the docker container images (not to be confused with active containers), use
    Code:
    docker images
    To delete an image use
    Code:
    docker rmi IMAGE
    where IMAGE can be the image name:tag or its ID.

  2. #2
    MyLilSuccy,

    Do you have an updated location for the files? I know this is a few years old, but I'm looking for a starting point.

    Thanks!

  3. #3
    I don't have any updates though I might still have them on my old machine. However I should be able to cook up some updated files. It might take me a bit to get them working.

  4. #4

    Feel better with a wide variety of non prescription drugs at our health web portal


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Our company offers a wide variety of non prescription drugs. Look at our health portal in case you want to look better with a help health products. https://kq23.athleticpharm.site/no/t...-xl-11658.html Our site offers a wide variety of non prescription products. Look at our health site in case you want to to feel healthier with a help of health products. https://9zh.athleticpharm.site/es/co...ate-21030.html Our company offers generic supplements. Visit our health contributing portal in case you want to look healthier. https://20bh.athleticpharm.site/de/n...nline-459.html Our company offers herb-based pills. Take a look at our health contributing portal in case you want to look better. https://j1d.athleticpharm.site/it/ac...one-32287.html Our company provides a wide variety of health and related products. Look at our health contributing portal in case you want to look better. https://j9k.athleticpharm.site/fr/su...z61-17991.html Our company offers a wide variety of non prescription drugs. Look at our health site in case you want to to feel healthier with a help health products. https://c68x.athleticpharm.site/fr/b...age-11180.html
    Our company provides supreme quality health products. Visit our health contributing portal in case you want to feel healthier. https://64wz.athleticpharm.site/it/p...ale-35311.html Our site offers a wide variety of non prescription drugs. Visit our health portal in case you want to look better with a help of generic supplements. https://fk43.athleticpharm.site/nl/k...man-21578.html Our company offers a wide variety of non prescription products. Visit our health portal in case you want to look healthier with a help health products. https://c02f.athleticpharm.site/fr/t...qp1c-6088.html Our company offers a wide variety of non prescription drugs. Take a look at our health portal in case you want to feel better with a help generic supplements. https://2x.athleticpharm.site/fi/jot...ope-33593.html Our company offers a wide variety of general health products. Look at our health contributing portal in case you want to improve your health.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •