Newcomer1989 / TSN-Ranksystem

A PHP Bot that assigns time based server groups on TeamSpeak3.
https://ts-ranksystem.com
GNU General Public License v3.0
142 stars 60 forks source link

TSN Ranksystem als Docker Container #705

Open mygrexit opened 4 years ago

mygrexit commented 4 years ago

Unterscheide, ob es sich um ein bestehendes oder ein neues Feature handelt....

Neue Funktion

*1) Was sollte dieses Feature tun?***

Das TSN-Ranksystem als fertigen Docker-Container anbieten.

*2) Wo soll es sich befinden? ***

Komplette Installation.

*3) Was wäre der Nutzen?***

Minimierung von Problemen mit PHP-Versionen, einfache Installation, kein Eingriff in das System des Users, Abschirmung von anderen Diensten und und und...

Ich kann natürlich einen eigenen Docker-Container erstellen, jedoch wird die Wartung dann die Hölle. Es wäre mega, wenn es direkt von Euch kommen würde.

mygrexit commented 4 years ago

Für alle, die es interessiert:

https://github.com/Kourgiantakis/docker-teamspeak-ranksystem

Ich habe nach meinem Post angefangen, mich selbst etwas mit Docker auseinanderzusetzen und muss meine Aussage zurückziehen. So eine Wartungshölle ist es für mich nicht. Man muss nur mal schauen, dass so Dinge wie die PHP aktuell bleiben. Das Ranksystem selbst aktualisiert sich ja innerhalb dockers.

Was ich damit sagen will: Ich habe meinen eigenen Container gemacht, ihr findet Ihn unter dem oben angegebenen Link.

JohannesBauer97 commented 3 years ago

+1 Would appreciate an official image from @Newcomer1989

Newcomer1989 commented 3 years ago

@JohannesBauer97 There won't be an official image yet, since I am not using docker. Also there is already a community image existing. Feel free to develope this an do a pull request on this repository.

Currently we prior other features.

jusito commented 3 years ago

First steps in this direction would help maintaining a docker image, most of them are debatable. Initial discussion started here: #541

E.g.: The docker way would be one container with one pinned version, no auto update. A new version would be in a another container, ofc. an additional container with auto update is possible but there is an important problem. Docker container should be minimal and if a new version needs additional dependencies, the update will break the current container because it doesn't have this dependencies. A better way would be like using semantic versioning for auto update, like x.y.z auto update only for z or new dependencies only on x+1 or something like this.

Because of this its important to know which files need to be persistent, e.g. dbconfig.php. A folder would be best, so if new files are "important" they can be added to this and they will not break it. To work best with docker, a folder which is expected to be empty on initial would be best. Persistent files are stored in docker volumes and volumes can only be mounted to folders. A mount like "Host: ~/dbconfig.php to Container .../dbconfig.php" is called bind mount and is sometimes forbidden. A common workaround is to create a volume which contains every file, e.g. complete ranksystem folder = volume. A new volume is empty, so if a volume is mounted to to a folder, its empty.

For easy testing and monitoring, supporting the docker health state would be very helpful. E.g. dockerimages can provide a "health state", if unhealthy the container can be restarted or if still unhealthy after restart recreated. I would just need a resource which is usable with wget / curl + grep, a simple "iam fine" or "not fine, because no connection to ts" or "not fine, update failed" is enough. (ok even a boolean fine: true/false would be enough for this) This would help to keep maintaining costs minimal, because this would allow automatic testing instead of manual.

According to the changes needed in my initial dockerimage after 2 years, which aren't adding features, the maintaining costs are already low. But with this features listed above, it could be completely automated - only new dependencies would require some sort of interaction. E.g. only real difference is another php version, one line of docker-php-ext-install mbstring and one line of docker-php-ext-enable mbstring

mygrexit commented 3 years ago

I agree with @jusito. Glad to see that you updated your image. You made some great additions and i will use yours myself.

@Newcomer1989, if you would be willing to help with jusitos suggestions, that would enable him to create an image which doesn't need any maintance and i think it would be great for the community.

Und noch etwas auf Deutsch: Ich kann nicht einschätzen wie viel Arbeit die Änderungen genau wären, aber ich denke es wäre im Verhältnis zum Mehrwert absolut sinnvoll.

Ich selbst habe leider keine Ahnung von PHP, sonst würde ich selbst Pull requests erstellen.

JVMerkle commented 3 years ago

In case you need some suggestions, I've managed to build a Docker & Docker-Compose setup around the rank system:

https://github.com/JVMerkle/TS3-Ranksystem/blob/master/docker-compose.yml https://github.com/JVMerkle/TS3-Ranksystem/blob/master/Dockerfile https://github.com/JVMerkle/TS3-Ranksystem/blob/master/docker-entrypoint.sh

The only necessary change regarding TSN-Ranksystem is the removal of the update procedure (=removing five lines of code). The contents of dbconfig.php are generated automatically depending on environment settings of the docker-compose.yml. There is also the possibility to enable the install mode with a simple INSTALL_MODE=1. The only thing I made persistent was the content of the tsicons folder, everything else is volatile.

Hope that helps, Regards

jusito commented 3 years ago

Thank you, it would greatly help to get your input:

  1. I haven't worked very much with apache 2 configuration yet, it would be great if you could explain why you added this change?

    RUN a2enmod remoteip rewrite
    RUN ( \
        echo "RemoteIPHeader X-Forwarded-For" && \
        echo "ErrorLog /dev/null" && \
        echo "CustomLog /dev/null combined" \
    ) >>/etc/apache2/apache2.conf
  2. Why do you remove this stuff? https://github.com/JVMerkle/TS3-Ranksystem/blob/master/docker-entrypoint.sh#L47-L55

  3. Why do you need persistant tsicons, shouldn't this be loaded from teamspeak without admin interaction or maybe it should be a general ranksystem feature?

JVMerkle commented 3 years ago
  1. The X-Forwarded-For is required for apache2 to accept the real client IP address from the proxy server. If you intend to connect your container directly to the internet you have to remove this. The apache module "rewrite" is not required (thanks for the reminder), whereas remoteip is required for the RemoteIPHeader option. The log options disable apache2 logging to the file system.
  2. I remove the install.php in normal operation mode for obvious reasons. But while in "install mode" the "regular files" are removed, so you do not forget to put it back in normal operation mode.
  3. I do not know at which interval the tsicons are fetched, but I noticed broken images when restarting the rank system.
jusito commented 3 years ago

added draft pr, feel free to join

JohannesBauer97 commented 2 years ago

I've created a prepared apache-php web server image for the TSN-Ranksystem. It gets automatically build and published once per month, to ensure security updates of PHP, Apache and their dependencies.

https://hub.docker.com/r/serverlein/tsn-ranksystem-webserver