• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[GitHub] OpenTibia 10.98, Raspberry Pi, Docker

silic0nalph4

Active Member
Joined
Aug 21, 2021
Messages
10
Reaction score
28
Location
Edron
Hi all,

I'm Silic0n Alph4, an anonymous code money who's fed up with Cipsoft :)

I've been playing Tibia with my sister since 200x. We each had periods of not playing, but finally a few years ago we both had stable Internet connections and enough free time to actually play. My wife joined us as well, and for a while it was awesome.

Then my sister got hacked.

She never shared her password, but she also hadn't changed it for over a decade, soo... 🤷‍♀️ Either way, Cip's response could be summarised as "fuck off". Even though it was clear from the market transactions, bank transfers, and TibiaCoin transfers who robbed her, Cip didn't want to help. After all these years of being a Cipsoft customer she'd had enough and refused to renew her premium account. My wife quit in sympathy, saying that a company that didn't respect their loyal players wasn't a company that she could support. This was a couple of years ago. I'm still a Premium account holder, but with nobody to play with the game is dead to me.

A couple of months ago I started looking into the state of the various OpenTibia servers and was blown away by just how advanced they've become. Despite playing Tibia for so long I've not looked into this stuff before, thinking that it was wrong to play on unofficial servers. Well, screw that, I'm all in.

I've been assembling a setup to run a real-map OpenTibia server on a Raspberry Pi 4B. I'm using Docker Compose, ForgottenServer 1.4/latest, ORTS2, and MyAAC. All the hard work has been done by the developers of those projects, but I hope that my efforts to bring them together, automate them, and document how it all works will be useful for other people. I'll be submitting PRs back to those projects as I go, and will keep everything I build open source. This setup is for Tibia 10.98 (TFS+ORTS2), but I play to build similar tools for deploying other versions of Tibia as projects reach maturity. I've had a play with OpenTibiaBR but don't have a working deployment yet.

The TFS+ORTS2 setup is running today on my Pi, and right now my sister is running around Tibia again for the first time in years. Thank you to everyone who has contributed to these amazing projects over years! Cipsoft may not live forever (especially with the way they treat their customers), but Tibia will.

Anyway, sorry for making you read all that! Here's the code: GitHub - silic0nalph4/nova-secura-10: An OpenTibia 10 (ForgottenServer + ORTS2) system for Raspberry Pi (https://github.com/silic0nalph4/nova-secura-10)
 

RIPSoft

∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞∞
Joined
Jun 27, 2016
Messages
166
Reaction score
55
What is raspberry pi except something you might want to eat?

Welcome, and, yeah, fk CIP bro forget about those douchefags. Both greedy and stupid them guys over at CIP.
 
OP
OP
silic0nalph4

silic0nalph4

Active Member
Joined
Aug 21, 2021
Messages
10
Reaction score
28
Location
Edron
Besides something very tasty, it's an ARM64-powered single-board computer that runs Linux... and prices start at £35. So it's small, cheap, low-power (ARM chips are widely used in mobile phones because of their low power consumption, and also form the basis of the new Apple M1 chips that have won so much praise), and can run almost any Linux software.

For the price, the performance is brilliant - I'm happy running ForgottenServer for three players on a Pi. I'm not sure it would hold up to hundreds of players online at the same time :) That's more of a question of how the resource usage of TFS scales with respect to players - is it linear, O(n^2), something worse, etc etc.

The exact hardware I'm using is:

So that totals up to around £157.50 for a Linux server that can sit in the corner running OpenTibia on Ubuntu. The SSD and case are optional, and I've not yet seen the server need all 8GB of RAM, so it would definitely be possible to build this out on a cheaper budget!
 

Adorius Black

Well-Known Member
Joined
Mar 31, 2020
Messages
143
Solutions
3
Reaction score
62
Welcome and thanks for your contribution :) . I have raspbery pi 4 almost 1 year in my box. So now I can start playing with it :D :p
 

MagicWall

Veteran OT User
Joined
Oct 12, 2008
Messages
112
Solutions
5
Reaction score
304
I thought about similar thing, great job.
I was planning learn kubernetes to make some similar, now from your docker swarm script I may learn a lot.

Now we may create additional web services for configure server, manage and configure database (create game master account / simple character/account editing) and remote server control (save/global clean/close etc.).

Helpful may be additional image with no-ip service with tutorial how to add and refresh no-ip service (or something similar).

The aim may be create template for new similar services (server+db+webpage), and make it as simple as possible.

I will be watching your project, and maybe I will try to add something :p
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,948
Solutions
252
Reaction score
1,891
Location
Norway
GitHub
Znote
Cool, I'm rocking a few Raspberry PI's myself at home. It works great as a dev server, or for new servers that havent built a playerbase yet.
Highest I have seen in terms of players online on a raspberry pi is about 30 players online on an TFS 1.2 10.98 server a couple years ago, no lag, and honestly plenty of hardware resources left to go. So its definitely viable as a startup gateway for a server. And a fun hobby project.

I like the way you set up your repository, I'm curious how you set up links to other repositories?
 
OP
OP
silic0nalph4

silic0nalph4

Active Member
Joined
Aug 21, 2021
Messages
10
Reaction score
28
Location
Edron
Thank you all for your kind words! It's great to be here 😁

I thought about similar thing, great job.
I was planning learn kubernetes to make some similar, now from your docker swarm script I may learn a lot.

I'd lean away from running OpenTibia on Kubernetes, personally. Kube is a great framework, but it's really designed for running clusters of stateless microservices that start quickly and can be terminated without any loss of data. You could run a clustered MySQL/MariaDB, website, and/or login server, but unless TFS has some features that I'm not aware of you'd have a bad time running it on k8s :(

Now we may create additional web services for configure server, manage and configure database (create game master account / simple character/account editing) and remote server control (save/global clean/close etc.).

I'm very onboard with this idea. The database schema should only be a concern of TFS - any tools built on top of it (websites etc) should interact with it via an API. Just because CIP implemented it one way doesn't mean that we should follow them absolutely 😁 I'd probably suggest implementing this functionality (accounts & server control) as an HTTP API on a separate port as part of TFS. Server admins could limit access so the port isn't exposed externally, but tools like MyACC could make server->server calls to the port to manage game state.

Helpful may be additional image with no-ip service with tutorial how to add and refresh no-ip service (or something similar).

The aim may be create template for new similar services (server+db+webpage), and make it as simple as possible.

I will be watching your project, and maybe I will try to add something :p

Good idea! I've been planning on setting up Dynamic DNS/no-IP for my home server at some point. Once I've got a setup that works I'll document it and link it from this thread. (And yes, PRs are welcome!) I'm also running a Wireguard VPN to allow secure access to the server. I'm not sure if anybody wants details on that, but it was surprisingly simple to set up.

Cool, I'm rocking a few Raspberry PI's myself at home. It works great as a dev server, or for new servers that havent built a playerbase yet.
Highest I have seen in terms of players online on a raspberry pi is about 30 players online on an TFS 1.2 10.98 server a couple years ago, no lag, and honestly plenty of hardware resources left to go. So its definitely viable as a startup gateway for a server. And a fun hobby project.

30 players is pretty decent! Was that a Pi 3 or 4? What resource constraints were you seeing - I'd assume that CPU usage scaled with the number of online players?

I like the way you set up your repository, I'm curious how you set up links to other repositories?

Thank you! I took inspiration from this repo that I found randomly: GitHub - Riicksouzaa/FerobraTfsDocker (https://github.com/Riicksouzaa/FerobraTfsDocker)

The links to the sub-repos are implemented using Git Submodules: nova-secura-10/.gitmodules at master · silic0nalph4/nova-secura-10 (https://github.com/silic0nalph4/nova-secura-10/blob/master/.gitmodules) I'd always heard that these were considered to be a poor implementation, but having used them for a few weeks I'm impressed. They're managed using the git submodule command, and each submodule is checked out as a complete Git repo with the main repo.

To work with them you just treat them as separate repos, cd in, make your changes & commit. You'll then notice that the changes to the submodules need to be committed to your top-level repo - this is because it's basically just storing a commit reference. You need to push both the main repo and the submodule repos separately. I don't think this is too much mental overhead, really, especially as it allows me to point my Docker Compose file at Dockerfiles within each repo directly.

The one drawback I have seen with submodules is that they seem to only allow one remote submodule. I'm using forks of TFS, MyAAC, and ORTS2 as I've got some WIP changes that I haven't submitted back to the main repos. This means I have to manually add upstream remotes to each submodules every time I want to update them 😟 A PITA, but a minor one!

I feel that I should also add that this whole setup was inspired by this unmerged PR: Docker compose support by Humberd · Pull Request #2758 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2758) I'm standing on the shoulders of giants!
 

drakylucas

Well-Known Member
Joined
Dec 15, 2015
Messages
189
Solutions
4
Reaction score
83
Hello,
this is a very good project! Thanks for your contribution to the community!

I'm totally newbie in containers/docker, but I'm trying to copy/paste some of your work to make a test here (without using ORTS).

I have a doubt. I could manage to run the website/database though Docker, but it seems every time I do docker-compose up, the ip changes and the website requires an update.
Lua:
In file install/ip.txt must be your IP!
In file is:
127.0.0.1
127.0.0.2
::1
Your IP is:
172.19.0.1
(The ip 172.19.0.1 changes all times when I restart all containers (docker-compose down / docker-compose up). Do you know if there's any way to make it not change?
I'm just doing some tests at home, without Raspberry so far, using docker for windows.


my current dockerfile (basically copied from you):

Code:
version: "3.0"

services:
  # The Forgotten Server
  # server:
  #   build:
  #     context: forgottenserver
  #     dockerfile: Dockerfile.clean
  #   restart: unless-stopped
  #   ports:
  #     - "7171:7171"
  #     - "7172:7172"
  #   depends_on:
  #     - db
  #   volumes:
  #     - ./forgottenserver/data:/srv/data # Mount world data pack from local copy
  #     - ./forgottenserver/config.lua:/srv/config.lua # Mount TFS config file from local copy

  # MyAAC Account Website
  web:
    build:
      context: myaac
    restart: unless-stopped
    ports:
      - 80:80
    depends_on:
      - db
    volumes:
      - ./forgottenserver/data:/srv/data # Mount world data pack from local copy
      - ./forgottenserver/config.lua:/srv/config.lua # Mount TFS config file from local copy

  # Maria DB
  db:
    image: mariadb
    restart: unless-stopped
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: "yes"
      MYSQL_USER: forgottenserver # Also needs to be set in config.lua
      MYSQL_PASSWORD: 123456 # Also needs to be set in config.lua
      MYSQL_DATABASE: forgottenserver # Also needs to be set in config.lua
    volumes:
      - ./state/db:/var/lib/mysql # Mount & persist the database storage locally rather than inside the container
      - ./forgottenserver/schema.sql:/docker-entrypoint-initdb.d/forgottenserver_schema.sql # Create TFS database schema on startup

  # Optional database admin tool (basically PhpMyAdmin)
  db-adminer:
    image: adminer
    restart: unless-stopped
    ports:
      - 8080:8080
(the server part is commented because I couldn't manage to make it work in Windows)



Regards,
Lucas
 
OP
OP
silic0nalph4

silic0nalph4

Active Member
Joined
Aug 21, 2021
Messages
10
Reaction score
28
Location
Edron
I have a doubt. I could manage to run the website/database though Docker, but it seems every time I do docker-compose up, the ip changes and the website requires an update.
Lua:
In file install/ip.txt must be your IP!
In file is:
127.0.0.1
127.0.0.2
::1
Your IP is:
172.19.0.1
(The ip 172.19.0.1 changes all times when I restart all containers (docker-compose down / docker-compose up). Do you know if there's any way to make it not change?
I'm just doing some tests at home, without Raspberry so far, using docker for windows.





Regards,
Lucas

Hey Lucas, I'm glad to hear that you've had a play with this! 😁

I wrote a few notes on how to set up the website here: GitHub - silic0nalph4/nova-secura-10: An OpenTibia 10 (ForgottenServer + ORTS2) system for Raspberry Pi (https://github.com/silic0nalph4/nova-secura-10#website-setup) but I haven't covered this exact scenario. As far as I can tell, the purpose of install/ip.txt is to provide a list of IP addresses that are allowed to access the installation wizard. We need to enter the IP address of the computer that we're connecting from - specifically, the IP address that the website container sees our connection request coming from. If we were going PC->Pi then it would just be our LAN IP address, but given we're going PC->PC I'd guess here that there's some sort of bridge/gateway IP address that lets the PC route into the Docker Compose cluster.

SSHing into my Raspberry Pi I think we can confirm that theory:

Code:
  IPv4 address for br-07ea08524c30: 172.30.0.1
  IPv4 address for br-7de3898944ce: 172.23.0.1
  IPv4 address for br-8d7080b22a09: 172.27.0.1
  IPv4 address for br-a8035750ef3c: 172.20.0.1
  IPv4 address for br-e20ec842d98f: 172.29.0.1
  IPv4 address for br-e2bdfc789cb5: 172.26.0.1
  IPv4 address for docker0:         172.17.0.1
  IPv4 address for eth0:            192.168.0.37

The Pi is running on my LAN as 192.168.0.37, but routes into my various Docker Compose clusters using those br bridge IP addresses.

The good news is that you're exposing port 80 on the website container as port 80 on your local machine:

Code:
ports:
      - 80:80 <-- Order is host:container

Any device on your network should be able to access MyAAC using the IP address or hostname of the machine running Docker.

TL;DR: Try http://localhost:80/install and see where that gets you.

My Docker setup for MyAAC is still rather rough & ready, hence why I haven't contributed it back to the main repo yet. The main things I'd like to get working before I do that are:
 
OP
OP
silic0nalph4

silic0nalph4

Active Member
Joined
Aug 21, 2021
Messages
10
Reaction score
28
Location
Edron
A small enhancement to my Nova-Secura Docker Compose cluster: automatic database exports using jan-di/docker-database-backup:


Fairly simple concept, great utility. The contents of the OT database are written out to ./state/db-backups/nova-secura-10_db_1.sql on the local file system. This allows for external backups and easy setting up test servers. I'm currently running it daily. The script currently always overwrites the file, but I'll be filing a feature request (and maybe a PR) to add a timestamp to the filename.
 
Top