Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief overview of PR changes/additions
Adds support for developing and running Evennia-based games in Docker containers. It includes a base Dockerfile that can be set up to automatically build and push images to Docker Hub, as well as a Dockerfile and docker-compose.yml file in the game_template that can be used by individual game developers to build images that contain both Evennia and their game.
See below for more detailed instructions on how to review this PR.
Motivation for adding to Evennia
This is certainly a nonessential addition to the framework, but it does provide a few benefits:
I can't say that it's categorically better or easier to use than a traditional python configuration, and most folks will probably want to still have their virtualenv set up so their IDEs can resolve classes, etc. However, putting this PR together has been helpful in my own learning about Docker containerization, and perhaps others may find it useful in that way too.
Other info (issues closed, discussion etc)
At present, I have published my base evennia image on docker hub as feend78/evennia. If this PR is accepted, I would follow up by publishing it at evennia/evennia and setting up automated builds out of github.
Setting Up
First, install Docker.
Download the image from docker hub with
docker pull feend78/evennia
Create a new Evennia game under the current directory:
docker run -it -v ${PWD}:/usr/src/game feend78/evennia evennia --init mudgame
Change to the newly created mudgame directory and build a runnable game image with the Dockerfile in the template.
cd mudgame
docker build -t feend78/mudgame .
Perform migrations
docker run -it -v ${PWD}:/usr/src/game feend78/mudgame evennia migrate
The last step of setup is to start the container once in interactive mode to create the superuser.
docker run -it -p 8000-8001:8000-8001 -p 4000:4000 -v ${PWD}:/usr/src/game feend78/mudgame
The above command line is recommended for use in development. It runs the container and exposes ports 8000, 8001, and 4000 on it to the host machine and maps the game directory to
/usr/src/game
so that any changes made to the source files on the local machine appear within the container and will be picked up with a standard@reload
.Entering all of those command line parameters each time you start your game server container becomes tiresome. Docker Compose is an orchestration tool most often used to control complex multi-container applications. Here, we use it to pre-set those command line options for development. It is installed automatically with docker for Windows and MacOS; and installation instructions for others can be found here.
With Docker Compose installed, starting the game container with the same options as above is just:
docker-compose up
The container can be stopped by running
@shutdown
in-game or by opening a second shell and issuingdocker-compose down
However, this currently results in an unclean shutdown, as evidenced by pid files that remain in the mudgame/server/ directory.