pvpgn / pvpgn-server

Next generation of PvPGN server
https://pvpgn.pro
GNU General Public License v2.0
554 stars 156 forks source link

Add Docker support #438

Closed aperture147 closed 3 years ago

aperture147 commented 3 years ago

Things has been made so far:

aperture147 commented 3 years ago

@RElesgoe Just updated Readme.md and docker-compose.yml, d2cs and d2dbs added. Please check this out. Btw have the mysql8 support added?

aperture147 commented 3 years ago

Some changes were made:

RElesgoe commented 3 years ago

When running one of the example commands,

docker build . --build-arg with_d2cs=true --build-arg with_bnetd=false --build-arg with_mysql=false --build-arg with_sqlite3=true --build-arg git_branch=develop -t pvpgn-server:d2cs-sqlite

The build errors with:

Cloning into 'pvpgn-server'...
error: pathspec 'develop' did not match any file(s) known to git
The command '/bin/sh -c apt-get update &&     apt-get install -y --no-install-recommends         git         netbase         ca-certificates         gcc g++         libc6-dev libc6         libc++-dev libc++1          zlib1g-dev zlib1g         libcurl4-openssl-dev libcurl4         cmake make         $(if ${with_mysql}; then echo "libmysqlclient-dev libmysqlclient21"; fi)         $(if ${with_sqlite3}; then echo "libsqlite3-dev libsqlite3-0"; fi)         $(if ${with_pgsql}; then echo "libpq-dev libpq5"; fi)         $(if ${with_odbc}; then echo "unixodbc-dev libodbc1"; fi)         $(if ${with_lua}; then echo "liblua5.1-0-dev liblua5.1-0"; fi) &&     git clone --depth=1 ${git_repo} pvpgn-server &&     cd pvpgn-server &&     git checkout ${git_branch} &&     cmake -G "Unix Makefiles" -S./ -B./build           -DWITH_BNETD=${with_bnetd}           -DWITH_D2CS=${with_d2cs}           -DWITH_D2DBS=${with_d2dbs}           -DWITH_LUA=${with_lua}           -DWITH_MYSQL=${with_mysql}           -DWITH_SQLITE3=${with_sqlite3}           -DWITH_PGSQL=${with_pgsql}           -DWITH_ODBC=${with_odbc} &&     cd build && make -j$(nproc) && make install &&     apt-get autoremove --purge -y         git         gcc g++         libc6-dev         libc++-dev         zlib1g-dev         libcurl4-openssl-dev         cmake make         $(if ${with_mysql}; then echo "libmysqlclient-dev "; fi)         $(if ${with_sqlite3}; then echo "libsqlite3-dev "; fi)         $(if ${with_pgsql}; then echo "libpq-dev "; fi)         $(if ${with_pgsql}; then echo "unixodbc-dev"; fi)         $(if ${with_lua}; then echo "liblua5.1-0-dev"; fi) &&     rm -rf /var/lib/apt/lists/* /build/pvpgn-server &&     apt-get clean' returned a non-zero code: 1
aperture147 commented 3 years ago

When running one of the example commands,

docker build . --build-arg with_d2cs=true --build-arg with_bnetd=false --build-arg with_mysql=false --build-arg with_sqlite3=true --build-arg git_branch=develop -t pvpgn-server:d2cs-sqlite

The build errors with:

Cloning into 'pvpgn-server'...
error: pathspec 'develop' did not match any file(s) known to git
The command '/bin/sh -c apt-get update &&     apt-get install -y --no-install-recommends         git         netbase         ca-certificates         gcc g++         libc6-dev libc6         libc++-dev libc++1          zlib1g-dev zlib1g         libcurl4-openssl-dev libcurl4         cmake make         $(if ${with_mysql}; then echo "libmysqlclient-dev libmysqlclient21"; fi)         $(if ${with_sqlite3}; then echo "libsqlite3-dev libsqlite3-0"; fi)         $(if ${with_pgsql}; then echo "libpq-dev libpq5"; fi)         $(if ${with_odbc}; then echo "unixodbc-dev libodbc1"; fi)         $(if ${with_lua}; then echo "liblua5.1-0-dev liblua5.1-0"; fi) &&     git clone --depth=1 ${git_repo} pvpgn-server &&     cd pvpgn-server &&     git checkout ${git_branch} &&     cmake -G "Unix Makefiles" -S./ -B./build           -DWITH_BNETD=${with_bnetd}           -DWITH_D2CS=${with_d2cs}           -DWITH_D2DBS=${with_d2dbs}           -DWITH_LUA=${with_lua}           -DWITH_MYSQL=${with_mysql}           -DWITH_SQLITE3=${with_sqlite3}           -DWITH_PGSQL=${with_pgsql}           -DWITH_ODBC=${with_odbc} &&     cd build && make -j$(nproc) && make install &&     apt-get autoremove --purge -y         git         gcc g++         libc6-dev         libc++-dev         zlib1g-dev         libcurl4-openssl-dev         cmake make         $(if ${with_mysql}; then echo "libmysqlclient-dev "; fi)         $(if ${with_sqlite3}; then echo "libsqlite3-dev "; fi)         $(if ${with_pgsql}; then echo "libpq-dev "; fi)         $(if ${with_pgsql}; then echo "unixodbc-dev"; fi)         $(if ${with_lua}; then echo "liblua5.1-0-dev"; fi) &&     rm -rf /var/lib/apt/lists/* /build/pvpgn-server &&     apt-get clean' returned a non-zero code: 1

Oh sorry, I forgot to commit some changes. Btw I'm on a Lunar New Year vacation and don't bring any computer with. I will fix this problem as soon as possible

aperture147 commented 3 years ago

@RElesgoe the problem is now fixed.

RElesgoe commented 3 years ago

Switch base image from default ubuntu to quay.io/aperture147/ubuntu to mitigate the impact of Docker Hub Pull Request Limits which can leads to failing CI build. This is an automated build from a synced-fork aperture147/docker-brew-ubuntu-core.

I prefer using the official Ubuntu image from the default container repository. If a user is experiencing rate limiting, they should modify the Dockerfile on their machine to avoid rate limiting.

After running

docker run -v /tmp/conf:/tmp/conf --rm --entrypoint cp pvpgn-server:bnetd-mysql /usr/local/etc/pvpgn/* /tmp/conf

I receive the following error:

cp: -r not specified; omitting directory '/usr/local/etc/pvpgn/i18n'

I receive similar errors when running

docker run -v /tmp/assets:/tmp/assets --rm --entrypoint cp pvpgn-server:bnetd-mysql /usr/local/var/pvpgn/* /tmp/assets

I also noticed that one of the commands specifies the mysql:8.0.23 image. Can we use mysql:8.0 or mysql:8 instead?

After running

docker run -d --name pvpgn-d2cs --restart unless-stopped -p 6113:6113 -p 6113:6113/udp -v /tmp/conf:/usr/local/etc/pvpgn -v /tmp/assets:/usr/local/var/pvpgn pvpgn-server:d2cs-mysql

I receive the following error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "bnetd": executable file not found in $PATH: unknown.

When checking the logs using

docker logs -f --tail 1000 pvpgn-bnetd

All I get is:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
You are currently running PvPGN 1.99.7.2.1-PRO
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you need support:
 * Create an issue at https://github.com/pvpgn/pvpgn-server

Server is now running.

Because bnetd is running in the foreground.

aperture147 commented 3 years ago

About changing the base image to official ubuntu:

Changed. According to this document, the rate limit is 100 pull per 6 hours so this might not affect this project's CI/CD

About getting error while copying base config files from the image:

Fixed. I forgot to add -r

About changing mysql version to 8.0 or 8:

In my opinion, locking mysql (or any image) to a specific version is a best practice, this might help us to figure the "best-known version" and make the debugging process easier. Changing mysql to latest or 8 will pull the latest version (currently 8.0 but could be 8.1 or 8.2 in the future) with (maybe) some breaking changes. Although mysql is pretty stable and libmysqlclient supports old version pretty well but to keep the best practice, I will only change the mysql version tag to 8.0.

About running specific build of d2cs and d2dbs cause error due to bnetd is missing:

This is my fault to hard-coded the CMD in the Dockerfile to bnetd -f. It's hard to figure out which server type the operator want to build, they can build an image which supports any combination of bnetd, d2cs and d2dbs so writing a script to predict the CMD command is not possible. My solution is adding another SERVER_TYPE env var to the image (which is set default to bnetd) and modify the CMD to $SERVER_TYPE -f. Anytime an operator wants to spin up a server, they have to choose an appropriate server type between between bnetd, d2cs and d2dbs. I've already push this change, do you have any better solution?

aperture147 commented 3 years ago

Another note, this command:

docker logs -f --tail 1000 pvpgn-bnetd

will continuously fetch the command with 1000 last lines of log of pvpgn-bnetd container, not the pvpgn-d2cs or pvpgn-d2dbs container. The error you get while running pvpgn-d2cs or pvpgn-d2dbs happens because the build doesn't include bnetd, which is mentioned in the "About running specific build of d2cs and d2dbs cause error due to bnetd is missing" part of the previous comment. Please check that out.

Btw you should turn off CI/CD whenever the README.md file is updated.

aperture147 commented 3 years ago

Do you guys use anything like discord, whatsapp or even IRC so we can contact more convenient.

RElesgoe commented 3 years ago

Do you guys use anything like discord, whatsapp or even IRC so we can contact more convenient.

#botdev at Discord - BNETDocs

cen1 commented 3 years ago

Dockerfile is good, small fix to compose and mostly readme fixes which I documented above. After next iteration I will also retest on Mac and Windows since it should work just fine in theory.

Best regards.

aperture147 commented 3 years ago

If I run with docker run pvpgn-server:bnetd-mysql I cannot kill the container with ctrl+c. Something catches the signal?

I'm running it as bnetd -D, so it's the one which catching the stop signal should be the bnetd itself. The default signal which docker sends is SIGTERM, after a few seconds or you hit the ctrl + c again then it will send SIGKILL. I don't know what is the meaning of "killing" the container, is it gracefully stop the container or make it stop immediately?

aperture147 commented 3 years ago

Dockerfile is good, small fix to compose and mostly readme fixes which I documented above. After next iteration I will also retest on Mac and Windows since it should work just fine in theory.

Best regards.

Thanks! I've resolved all of the issues mentioned. This build is tested on Linux and I'm running it on my server which has approx 200 - 300 unique users daily (most of them play DotA with my hosted ghost++).

If this build works on linux then 99% it will run on windows and macos too since docker on those system is running on a VM. If there are errors, most of the time it would be networking misconfiguration.

cen1 commented 3 years ago

Left a couple more comments. Just need to test Windows and we are almost there.

aperture147 commented 3 years ago

Finished!

cen1 commented 3 years ago

@aperture147 please check the 4 pending comments above. The mysql config string is the important one, the rest I can close myself.

aperture147 commented 3 years ago

@aperture147 please check the 4 pending comments above. The mysql config string is the important one, the rest I can close myself.

But I don't see any new comment :( Resolved all 5 issues above. Am I missing anything? image

cen1 commented 3 years ago

@aperture147 please check the 4 pending comments above. The mysql config string is the important one, the rest I can close myself.

But I don't see any new comment :( Resolved all 5 issues above. Am I missing anything? image

My bad, I forgot to actually submit the review. :insert facepalm:

aperture147 commented 3 years ago

just resolved your issue above. Please check!

cen1 commented 3 years ago

I had some issues with modern firewalld blocking internal docker container comms but I will patch the readme mysql with that info and fix the language a little bit. All seems to work fine, I made it to the login.