• 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!

PHP Running mysql/my-acc/forgottenserver.exe using Docker / docker-compose

drakylucas

Intermediate OT User
Joined
Dec 15, 2015
Messages
235
Solutions
7
Reaction score
121
Hi all, good afternoon, how are you doing?

I'm a totally newbie in Containers/docker.
Can someone please explain step by step to put mysql, website and the TFS running through containers?

without having to compile the server, I imagine this file structure:
folders:
otserver
otserver/forgottenserver <-- this will be the main folder which contains "theforgottenserver-x64.exe" (previously compiled)
otserver/docker <-- this should be the folder that will contain all Dockerfiles and the docker-compose.yml I think, but I'm not sure
otserver/website <-- This should be the folder with my-acc website (the folder with index.php file) (slawkens/myaac (https://github.com/slawkens/myaac))


I imagine something like this:
a Dockerfile to run forgottenserver.exe
a Dockerfile to run mysql (and also run the schemas.sql, but it should load the database stored in computer and not recreate it every time)
a Dockerfile to run php7 / nginx

a docker-compose that compose all these dockerfiles into a single file and starts both website/tfs.

can someone help me understanding Docker? thanks in advance!
Post automatically merged:

so far I tried this:


YAML:
version: "3.7"
services:
  db:
    image: mariadb
    container_name: "mariadb-container"
    restart: unless-stopped
    environment:
      - MYSQL_DATABASE=otserver
      - MYSQL_USER=otserver
      - MYSQL_PASSWORD=otserver
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
    volumes:
      - ./db-volume:/var/lib/mysql
    ports:
      - "3306:3306"

  website:
    image: webdevops/php-nginx:7.4-alpine
    container_name: "myaac-website"
    restart: unless-stopped
    environment:
      - WEB_DOCUMENT_ROOT=/tmp/web/
      - WEB_DOCUMENT_INDEX=index.php
    ports:
      - "80:80"
    depends_on:
      - db
    volumes:
      - ../website/myaac:/tmp/web

docker-compose up
added schemas.sql into /db-volume folder
docker exec -it mariadb-container /bin/bash
cd /var/lib/mysql
mysql -u otserver -p otserver < schema.sql <--- so the schemas was actually copied to the database "otserver"

I don't know if this is the right way of adding the schemas.
after all these steps, I could access 127.0.0.1 website but, myaac is telling me this:

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

I'm still searching, but is there any way to set my container IP being the same of my computer (127.0.0.1)?
anyway, I changed my ip in install/ip.txt to 172.19.0.1 and it's working.

now, another doubt:
while configurint myaac, it asked me the path of my TFS folder (Path to your TFS main directory, where you have config.lua located.)
I added this:
C:\Users\Lucas\Desktop\OTServer\forgottenserver

but it couldn't find config.lua
Cannot find config.lua file. Is your server path correct? Go back and check again.

I think this is because actually, when the container starts, he only have access to "
../website/myaac" in my computer.
Should I also share my TFS volume in this case?

also, I still need to add the start of forgotten-server in docker-compose.yml file.
 
Last edited:
Sorry for late answer.

Currently I am playing with docker too.

To answer your question: Yes you need to either share tfs volume with myaac, or copy config.lua and data/ folder to the same container where myaac is located.

I will try to experiment with this more, and when I got a working solution, I will share it.
 
It could help. TFS 1.4.2 in docker compose.

If You need read config.lua from container put it as volume.
You need fix Dockerfile to use new alpine linux to create image.
 
There’s already a Dockerfile (forgottenserver github) which you can use to build tfs image. Just create a stack that constists of tfs-image & mysql-server image (mysql) and expose some major ports port game/login/sql. In adition you can mount a volume with custom data directory

Edit: I’m going to work on that soon to use it on docker with some prometheus metrics so I can post it once its ready.
 
There’s already a Dockerfile (forgottenserver github) which you can use to build tfs image. Just create a stack that constists of tfs-image & mysql-server image (mysql) and expose some major ports port game/login/sql. In adition you can mount a volume with custom data directory

Edit: I’m going to work on that soon to use it on docker with some prometheus metrics so I can post it once its ready.
Yes, there is Dockerfile.
But... on 1.4.2 it's broken. You need to change alpine version inside.
 
docker build -t tfs:latest .
docker swarm init
docker stack deploy --compose-file stack.yml opentibia

Code:
version: '3.7'
x-ot-service: &ot-service
  networks:
    - ot-net
networks:
  ot-net:
volumes:
  database-data:
services:
  server:
    <<: *ot-service
    image: tfs:latest
    ports:
      - 7171:7171
      - 7172:7172
    volumes:
      - "./config.lua:/srv/config.lua"
      - "./key.pem:/srv/key.pem"
    depends_on:
      - database
  database:
    <<: *ot-service
    image: mysql/mysql-server:latest
    command: --default-authentication-plugin=mysql_native_password
    ports:
     - 3306:3306
    volumes:
      - database-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: "secret_password"
      MYSQL_DATABASE: "forgottenserver"
      MYSQL_USER: "forgottenserver"
      MYSQL_PASSWORD: ""
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
      MYSQL_ROOT_HOST: "%"

key.pem & config.lua in stack.yml directory
Lua:
mysqlHost = "database"
mysqlUser = "root"
mysqlPass = "secret_password"
mysqlDatabase = "forgottenserver"
mysqlPort = 3306
mysqlSock = ""
Connect to MySQL, import DB and ready.

NOTE: It's for debugging use only, no need to use swarm but this is simply how I use it for debugging.

1677857647782.png
 
Last edited:
Been trying to run a very similar setup, but haven't been able to troubleshoot what's hapenning. My docker-compose looks very similar

YAML:
version: '3.8'
services:
  db:
    image: mysql
    container_name: "mysql_tfs"
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password --log_bin_trust_function_creators=1
    environment:
      - MYSQL_ROOT_HOST="%"
      - MYSQL_DATABASE=tfs
      - MYSQL_USER=tfs
      - MYSQL_PASSWORD=tfs
    volumes:
      - ./db-volume:/var/lib/mysql
    ports:
      - 3306:3306
 
  tfs:
    image: giorox/angelion-tfs:1.0.0
    container_name: "server_tfs"
    restart: on-failure
    ports:
      - "7171:7171"
      - "7172:7172"
    depends_on:
      - db
    volumes:
      - .:/srv
      - "./config.lua:/srv/config.lua"
      - "./key.pem:/srv/key.pem"

Haven't been able to get past the "Loading lua scripts" step of the server startup. It quietly dies with either code 0 or code 139 (which is Segfault IIRC), anyone have any suggestions on troubleshooting steps?


1687117844660.png
 
Back
Top