Skip to content

Docker compose support#2758

Closed
Humberd wants to merge 13 commits intootland:masterfrom
Humberd:docker-compose-support
Closed

Docker compose support#2758
Humberd wants to merge 13 commits intootland:masterfrom
Humberd:docker-compose-support

Conversation

@Humberd
Copy link

@Humberd Humberd commented Jan 6, 2020

Docker Compose

There is also a way of running the server + database at once using docker-compose.
By default it:

  • Creates a database named forgottenserver.
  • Executes schema.sql file, so that you don't have to manually import it.
  • Saves all the database files inside a ./db local directory.
Preparation:
  1. Update your configu.lua.dist with these values, so that server properly connects to the database:
-- MySQL
mysqlHost = "db"
mysqlUser = "forgottenserver"
mysqlPass = "<your_db_password>"
mysqlDatabase = "forgottenserver"
mysqlPort = 3306
mysqlSock = ""
  1. Change your database user password by replacing
    <your_db_password> with your password of choice.
    Remember to also update it in docker-compose.yml.

  2. Change your database root password by replacing
    <your_root_password> in docker-compose.yml.

Start:
docker-compose up -d
Stop:
docker-compose down
Rebuild container after source code changes:
docker-compose up -d --build

Created services:

  1. The Forgotten Server - localhost:7171, localhost:7172.
  2. Database - direct connection hidden to the outside world.
  3. Database explorer - localhost:8080. Allows viewing what's inside the database.

Docker-compose issues:

  1. During startup the server container is created after database, however, the database might not be initially available.
    This is why the server will restart a couple of times before it successfully establishes the connection.

  2. If you are using Docker Toolbox for Windows and it uses VirtualBox,
    then the server and database explorer address host name will be 192.168.99.100 insead of localhost.

@ghost
Copy link

ghost commented Jan 7, 2020

are those changes on config.lua.dist really necessary?

@DSpeichert
Copy link
Member

See #2687

@Humberd
Copy link
Author

Humberd commented Jan 10, 2020

@EPuncker yea, you are right. Will remove it later today

@Humberd
Copy link
Author

Humberd commented Jan 10, 2020

@DSpeichert my changes are simpler and dont require additional scripts

@Humberd
Copy link
Author

Humberd commented Jan 12, 2020

@EPuncker I reverted all the changes from config.lua.dist. User now has to configure database connection by himself. What is more I added detailed description what to edit in the README.

@Humberd
Copy link
Author

Humberd commented Jan 23, 2020

Bump

@Humberd Humberd requested a review from DSpeichert January 23, 2020 19:17
@soul4soul
Copy link
Contributor

This project don't use the repo for documentation. This project uses the wiki feature of github for documentation. Consider undoing the changes to the readme.md. Update the OP to include code blocks with the any documentation you have written. Promise you will update the wiki with the new docker documentation if these changes are merged.

I don't think anyone would object to you adding a 3rd bullet point under the Getting Started header which links directly to a new docker wiki page.

@Humberd
Copy link
Author

Humberd commented Jan 23, 2020

@soul4soul Removed documentation from README. To add new wiki page I would need some permissions.

@Znote
Copy link
Member

Znote commented Jan 24, 2020

image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: <your_root_password>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try MYSQL_RANDOM_ROOT_PASSWORD: '1'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use MYSQL_RANDOM_ROOT_PASSWORD instead. It does not need a root account at all, and the less privileges, the better.

environment:
MYSQL_ROOT_PASSWORD: <your_root_password>
MYSQL_USER: forgottenserver
MYSQL_PASSWORD: <your_db_password>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of that, try running both containers in the same network namespace and run a script that allows no password from localhost for the user.

Alternatively, try sharing a unix socket and using https://mariadb.com/kb/en/authentication-plugin-unix-socket/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DSpeichert that's not trivial with Docker, and I think he wants the password to be used in this "adminer" container below - I didn't even Google it, but it looks like phpMyAdmin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing unix socket may not be easy due to uid mapping but sharing network namespaces is very easy with docker-compose:

...
services:
  db:
    ...
  pma:
    network_mode: "service:db"
    ...
...


* [Compiling](https://github.com/otland/forgottenserver/wiki/Compiling), alternatively download [AppVeyor builds for Windows](https://ci.appveyor.com/project/otland/forgottenserver)
* [Scripting Reference](https://github.com/otland/forgottenserver/wiki/Script-Interface)
* [Docker Compose](https://github.com/otland/forgottenserver/wiki/Docker-Compose)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this up a line, because compiling and docker are in a similar sphere related to service deployment, whereas scripting is in the sphere of dataset content creation.

image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: <your_root_password>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use MYSQL_RANDOM_ROOT_PASSWORD instead. It does not need a root account at all, and the less privileges, the better.

MYSQL_DATABASE: forgottenserver
volumes:
# Saves all the data in ./db directory
- ./db:/var/lib/mysql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a volume here, instead of relying on the host file system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unusually hard to fish the files out of a docker-managed volume and the point here is for the data to persist, so I think this is the easy to understand option here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you want to extract raw files from a database storage? It's not like you can do anything more with them out of the container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can back them up and run a server out of them, see mariabackup etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do the very same with volumes, just prepend docker exec to the same mysqldump -u <user> -p <password> <db> you would run.

environment:
MYSQL_ROOT_PASSWORD: <your_root_password>
MYSQL_USER: forgottenserver
MYSQL_PASSWORD: <your_db_password>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DSpeichert that's not trivial with Docker, and I think he wants the password to be used in this "adminer" container below - I didn't even Google it, but it looks like phpMyAdmin.

silic0nalph4 added a commit to silic0nalph4/forgottenserver that referenced this pull request Sep 6, 2021
@gesior
Copy link
Contributor

gesior commented Jan 13, 2022

I think we should also change:

RUN cmake .. && make

to:

RUN cmake .. && make -j $(nproc)

in Dockerfile or make it use shared build folder, to do not recompile all files, after every little change in .cpp file.

@DSpeichert
Copy link
Member

Closing this as abandoned, but it could use a refresh and maybe make its way into the wiki instead.
There seems to be so many ways of running TFS, it may not be worth adding each method to the source repo.

@DSpeichert DSpeichert closed this Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants