godarklight / DarkMultiPlayer

DarkMultiPlayer - A multiplayer mod for Kerbal Space Program
MIT License
278 stars 120 forks source link

Simple Dockerfile to use the server in a Dockercontainer #447

Closed deluxe2 closed 5 years ago

deluxe2 commented 5 years ago

Wanted to run the server into a Dockercontainer. So i made this and thought i should share it with everyone who wants to do the same.

Added Dockerfile and some basic Documentation.

Changed the directories for some config files to allow docker to mount a single config directory with all the files which my be edited. Probably needs a migrationfeature for the moved files.

If you have improvements name them so i can make this better. Also if you dont want to merge this please send a short response and close this issue.

Xinayder commented 5 years ago

Why not mount the whole server folder instead of mounting separate folders?

deluxe2 commented 5 years ago

I tried to only mount folder wich should be persistant and/or need to be modified by the User. So if you update the server build a new Container run it with the same volume or mount and everything is up and running. You don't need to worry about the binaries. Everything you don't need to edit is hidden inside the container.

Desired way to update:

git pull
docker build -t dmp-server:[version] .
docker run docker run -d \
  -p 6702:6702 \
  -v [path/on/host]:/DMP/Config \
  -v dmpsave:/DMP/Universe \
  dmp-server:[version]

I hope this makes my intentions clear. I'm not used to write such things in english. If questions arise just ask.

Xinayder commented 5 years ago

Okay. What about the other ports that should be exposed, like the JSON status page? Or the RCON (#444) protocol?

deluxe2 commented 5 years ago

You can just add another -p [hostport]:[containerport] to your docker run command.

deluxe2 commented 5 years ago

If it's okay and you don't want to merge the changes I made. I would like to make containers and share them on dockerhub. Everytime you release a new version I would make a new image. Also improve the documentation to match more use cases and provide support if needed.

Xinayder commented 5 years ago

It's possible to setup a deploy script to automatically build new images when a new version is released. I'll take a look at it.

EDIT: I forgot to mention, maybe as a way to prevent this from being a breaking change (and having to setup a way to migrate the old config files), there could be a setting, called isContainer, which, if set to true, changes the location of ban files.

Xinayder commented 5 years ago

I've slightly changed your commit, but maintained you as the author. The server files are in /server/ and the previous commit moved any config file to Config/, making it accessible via /server/Config/. I'll add a small documentation for the Docker image and will try setting up automatic builds.

Thank you!

deluxe2 commented 5 years ago

Nice way to sort all the problems out. Do you need an updated version of the docker-readme? The one i commited was just a quick write-up to demonstrate the basic features.

EDIT: I found the documentation to setup automated builds on DockerHub: https://docs.docker.com/docker-hub/builds/