I decided to finally get my head wrapped around Docker, and decided to resurrect one of my favorite games from years ago mostly to see if I could. In retrospect I probably should have experimented with a piece of software written in this decade but... I got it to work so I can't really complain. I should note that this post and related posts will assume you know at least a bit about dockers concepts and the linux command line to get everything up and running, you'll also need to know a bit about Linux for all of this to make any sense.
Initially I was convinced (CONVINCED) I wanted to build this and another related docker box using the 'busybox' base image because smaller is better right? You'll notice the image is now based on CentOS, because I gave up on that plan entirely. This was mostly due to the fact that busybox's wget can't do https, it may be missing other tools too but without that it was out to begin with.
That out of the way lets list out a few things to know about the jaserv binary and configuration:
- The server is a 32-bit binary, by default the images pulled into docker do not support this but fixing that is pretty easy we just need to add the 32-bit glibc.
- These files can be a total pain to track down, to solve this I've placed them into my Drobox Pro public folder which should have plenty of bandwidth for these tiny little zips. The provided Dockerfile uses these versions of the files, I couldn't guarantee they wouldn't move otherwise.
- The published behavior of these executables and their actual behaviors don't match up 1:1 so getting things working will take a bit of prodding, and unfortunately makes the docker container a bit leaky (but still useful). The Docker file included works around this, but will require you to replicate the directory structure below for it to work.
- The way the binary launches it needs a tty interface in order to function correctly, which docker does not provide by default and if you don't realize that it will drive you mad. So provide the '-t=true' when you issue your docker run commands or it will not work, the startup script below does this.
- For the base server configs you will find the 'chopservers' article on running home servers to be an immense help.
So how do we put all of this information together to actually make a functional server? First, you need to make sure docker is installed. You will also need a copy of Jedi Knight: Jedi Academy, and more specifically the 'base' folder included in the install. A copy can be had for ~$10 on GoG or Steam, and will be necessary to make this work.
I suggest creating a project folder with the following directory structure:
jaservdock: Dockerfile <- from gist below jaservlaunch.sh <- from gist below base: jediknight pk3 files <- pk3 files from JK cd or steam/gog download jampgamei386.so <- must be extracted from zip file server.cfg <- text file you must create, reference copy below
There's a bit to unpack here, the root level folder holds the Dockerfile (spelled very specifically 'Dockerfile'), a simple launching script and the 'base' folder from the official version of the game. Added to the base folder of the game are a the shared object jampgamei386.so file extracted from one of the zip files linked above and your desired server config file. This is where the dockerfile gets a bit leaky, ideally that shared object file should not be there. Unfortunately I could not make the server run without it sitting inside the 'base' dir the server binary runs against, despite other documents mentioning no such requirement. However if you want to make multiple servers you can simply copy it to a central location and generate symlinks in the folder structure to handle this for you.
Once this folder structure is created as root run
docker build -t wildcarde/jaserv . while in the 'jaservdock' folder. This will take some time to assemble the docker container on your system's hard drive.
After it is completed you can attempt to launch it with the 'jaservlaunch.sh' script that is included at the end of the document. You will need to run this script as root and make sure to make it executable with
chmod +x ./jaservlaunch.sh before trying to use it or it will not work. You will also need to update
-v /jaserverdoc:/data with the path folder you want to launch your docker image out of (specifically the folder that 'base' is located inside of). This path must be the full path to the file and not a relative path as per docker's requirements.
If docker launches the server as expected you should be able to join it via machines on the local network by simply selecting 'Lan' in the multiplayer server list. If you'd like to see the logs for the docker container the command
docker logs jaserv will show you the current logged state of the server process.
And that's it, update the server.cfg file to do what you'd like it to do or use the one below. If you want to disable specific force powers or weapons just use this jaserv calculator sheet and add the output code to the server.cfg file.
Future Work: I suspect at some point in the future I will remake this docker file so that it's git cloning the openjk version from github and building it in place. Supposedly this version has seen a couple updates and adjustments that make it function a bit better, hopefully it also improves the server advertisement situation because it's pretty broke right now.
TL; DR: It works! If you know your way around docker the docker file should work out of the box, but you might want to alter the startup file so it's not using ''--net=host'. Have Fun!