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

Compiling How to run old tfs on docker?

hiwyn

Member
Joined
Aug 30, 2021
Messages
78
Reaction score
8
I was creating a project by using 0.4 sources on debian 9
Now that i move to debian 11, i couldn't manage to compile/run my project

I tried to run it on docker (idk how to work with docker)

Thats the Dockerfile:
Code:
FROM debian:9

COPY sources.list /etc/apt/
RUN apt-get update
RUN apt-get install -y autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libssl-dev libsqlite3-dev
RUN apt-get install -y libmariadbclient-dev

COPY . .

RUN cd 3777/src/
RUN make -j`nproc`
RUN mv tfs ../../
RUN cd ../../
RUN ./tfs


EXPOSE 7171

When i use docker build . -t debian9
it prints:
Code:
Sending build context to Docker daemon  385.3MB
Step 1/12 : FROM debian:9
 ---> 8701ac7aec56
Step 2/12 : COPY sources.list /etc/apt/
 ---> Using cache
 ---> 30cb8daa28b3
Step 3/12 : RUN apt-get update
 ---> Using cache
 ---> 21350e86ef35
Step 4/12 : RUN apt-get install -y autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libssl-dev libsqlite3-dev
 ---> Using cache
 ---> ffc37e2a7ad6
Step 5/12 : RUN apt-get install -y libmariadbclient-dev
 ---> Using cache
 ---> 16d2d09e581c
Step 6/12 : COPY . .
 ---> 04087ad9769f
Step 7/12 : RUN cd 3777/src/
 ---> Running in d8b3fa3d81ee
Removing intermediate container d8b3fa3d81ee
 ---> 11eb90b9d725
Step 8/12 : RUN make -j`nproc`
 ---> Running in 34fa974edf91
make: 'run' is up to date.
Removing intermediate container 34fa974edf91
 ---> ac2b2d86c0b3
Step 9/12 : RUN mv tfs ../../
 ---> Running in 6cc5f99a07f3
mv: 'tfs' and '../../tfs' are the same file
The command '/bin/sh -c mv tfs ../../' returned a non-zero code: 1

What i'm doing wrong?
 
Solution
If anyone need to run fir3elemental/3777 on new debian/ubuntu here is updated version:
Changelog to make it compile on Ubuntu 20.04:

Dockerfile for Debian 11 that compiles updated fir3elemental/3777:
Code:
FROM debian:11

RUN apt-get update

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London

RUN apt-get -y install tzdata

RUN apt-get -y install git cmake build-essential zip wget ca-certificates pkg-config autoconf pkg-config automake

RUN cd /home/ && git clone --depth 1 https://github.com/gesior/3777.git

RUN apt-get -y install libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libmariadb-dev-compat...
Code:
RUN cd 3777/src/
RUN make -j`nproc`
RUN mv tfs ../../
RUN cd ../../
RUN ./tfs
Every command 'RUN' starts in / path. If you want to 'cd' to some directory and execute something there, you must use '&&':
Code:
RUN cd 3777/src/ && make -j`nproc` && mv tfs ../../
RUN ./tfs
Anyway, you replaced:
Code:
/autogen.sh && ./configure --enable-sqlite --enable-mysql --enable-root-permission --enable-server-diag && ./build.sh
with:
Code:
make -j `nproc`
and it will probably do nothing.

To compile fir3elemental/3777, you can use this Dockerfile:
Code:
FROM debian:9

RUN apt-get update

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London

RUN apt-get -y install tzdata

# 1: forgottenserver (TFS)
RUN apt-get -y install git cmake build-essential zip wget ca-certificates pkg-config autoconf pkg-config automake

RUN cd /home/ && git clone --depth 1 https://github.com/Fir3element/3777.git

RUN apt-get -y install libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libmariadb-dev-compat libssl-dev libsqlite3-dev \
    libmariadb-dev-compat libboost-date-time-dev libboost-filesystem-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev zlib1g-dev

RUN cd /home/3777/src && chmod +x autogen.sh build.sh && ./autogen.sh && ./configure --enable-sqlite --enable-mysql --enable-root-permission --enable-server-diag && ./build.sh && mv theforgottenserver ../tfs
RUN ./home/3777/tfs
BUT IT DOES NOT WORK! C++ code is not compatible with c++ compiler on Debian 9.
TFS 0.4 3777 was made in times of DEBIAN 5!

You should update these sources to make them compatible with Debian 11. Tutorial:
If you get any new error - not listed in tutorial - you can contact me on Discord: Gesior.pl#3208
 
Thank you @Gesior.pl , you were right, RUN starts on /

Sorry, didn't know, first time creating a Dockerfile...

---

About 3777 don't work on debian 9, i've follow a tutorial a long time ago (when i start to use debian 9)
That create a file in 3777/src/Makefile

Code:
SRC = actions.cpp admin.cpp allocator.cpp baseevents.cpp beds.cpp chat.cpp\

      combat.cpp condition.cpp configmanager.cpp connection.cpp container.cpp\

      creature.cpp creatureevent.cpp cylinder.cpp database.cpp\

      databasemanager.cpp databasemysql.cpp databasesqlite.cpp depot.cpp\

      dispatcher.cpp exception.cpp fileloader.cpp game.cpp gameservers.cpp\

      globalevent.cpp group.cpp house.cpp housetile.cpp ioban.cpp ioguild.cpp\

      iologindata.cpp iomap.cpp iomapserialize.cpp itemattributes.cpp item.cpp\

      items.cpp luascript.cpp mailbox.cpp manager.cpp map.cpp monster.cpp\

      monsters.cpp movement.cpp networkmessage.cpp npc.cpp otserv.cpp\

      outfit.cpp outputmessage.cpp party.cpp player.cpp position.cpp\

      protocol.cpp protocolgame.cpp protocolhttp.cpp protocollogin.cpp\

      protocolold.cpp quests.cpp raids.cpp rsa.cpp scheduler.cpp\

      scriptmanager.cpp server.cpp spawn.cpp spells.cpp status.cpp\

      talkaction.cpp teleport.cpp textlogger.cpp thing.cpp tile.cpp tools.cpp\

      trashholder.cpp vocation.cpp waitlist.cpp weapons.cpp


OBJ = ${SRC:.cpp=.o}


CC = g++

INCS = -I/usr/include/libxml2 -I/usr/include/lua5.1 -I.  

CPPFLAGS = -DHAVE_CONFIG_H -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT

CXXFLAGS = -std=c++03 -Os -fomit-frame-pointer -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pipe ${INCS} ${CPPFLAGS}

LDFLAGS = -s -llua5.1 -lmariadbclient -lcrypto -lboost_filesystem -lboost_date_time -lboost_system -lboost_regex -lboost_thread -lz -lgmp -lxml2 -pthread

all: options tfs


options:

    @echo tfs build options:

    @echo "CXXFLAGS = ${CXXFLAGS}"

    @echo "LDFLAGS  = ${LDFLAGS}"

    @echo "CC       = ${CC}"


.cpp.o:

    @echo '${CC} $<'

    @${CC} -c ${CXXFLAGS} $<


tfs: ${OBJ}

    @echo CC -o $@

    @${CC} -o $@ ${OBJ} ${LDFLAGS}


clean:

    @echo cleaning

    @rm -f tfs ${OBJ}


.PHONY: all clean options

Code:
make -j`nproc`
works before, and looks works on docker too

I'll try to make it compatible with debian 11, just a opotunity to do something with docker, and a way to still run my server easily

---

With this Dockerfile to run the server:
Code:
FROM debian:9

COPY sources.list /etc/apt/
RUN apt-get update
RUN apt-get install -y autoconf build-essential pkg-config automake libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libssl-dev libsqlite3-dev
RUN apt-get install -y libmariadbclient-dev

COPY . .

RUN cd 3777/src/ && make -j`nproc`
RUN cd 3777/src/ && mv tfs ../../
RUN ./tfs

EXPOSE 7171 7172

it stops on ./tfs
Code:
Step 9/10 : RUN ./tfs
 ---> Running in 6a953a60a017
[17:33:28.793] The Forgotten Server 0.4

[17:33:28.793] >> Loading config (config.lua)
[17:33:28.795] >> Opening logs

>> Loading Demon Oak Lib V0.70 REV: 1 (June 26 2012) By Darkhaos (Contact: http://otland.net/members/darkhaos/)

[!] -> Checking demon oak lib...
[!] -> 0 problems loaded in 0.000176 seconds.

[!] -> Demon Oak Lib loaded in 0.001545 seconds.

tfs: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:102: boost::condition_variable::~condition_variable(): Assertion `!ret' failed.
[17:33:28.965] > Using SHA1 encryption
[17:33:28.965] >> Loading RSA key
[17:33:28.965] >> Starting SQL connection
[17:33:29.022] Failed connecting to database - MYSQL ERROR: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") (2002)

[17:33:29.022] > ERROR: Couldn't estabilish connection to SQL database!
Aborted (core dumped)
The command '/bin/sh -c ./tfs' returned a non-zero code: 134

It shouldn't work with my MSQL?
I mean, i have in my computer?
I put my local IP on config.lua...
 
It's very complicated to run anything with docker. There is separate network with different IPs for your local machine and docker container. Try to make .cpp/.h files work with Debian 11 libraries. It should be just few changes.

I do not recommend to run any server using docker. You can waste weeks on fixing bugs that occured, because of using docker. I use it only to test, if code XX compile on YY system.
 
Windows docker btw:

I could run it inside a docker container but...
I couldnt find a way to connect to the server after the character list, binding to 0.0.0.0 didn't work with tfs 0.4 at least
and external ip wouldnt work either inside docker so I think it's a dead end :S

EDIT: couldn't find a way to bind the external ip using docker, I dunno much about docker on windows network internals
but default windows wsl2 ran just fine using port forward (netsh interface)
fun to test the server on windows without having the trouble to compile for windows (could never make a successful tfs 0.4 build for x64 on windows)
 
Last edited:
If anyone need to run fir3elemental/3777 on new debian/ubuntu here is updated version:
Changelog to make it compile on Ubuntu 20.04:

Dockerfile for Debian 11 that compiles updated fir3elemental/3777:
Code:
FROM debian:11

RUN apt-get update

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London

RUN apt-get -y install tzdata

RUN apt-get -y install git cmake build-essential zip wget ca-certificates pkg-config autoconf pkg-config automake

RUN cd /home/ && git clone --depth 1 https://github.com/gesior/3777.git

RUN apt-get -y install libboost-all-dev libgmp3-dev libxml2-dev liblua5.1-0-dev libmariadb-dev-compat libssl-dev libsqlite3-dev \
    libmariadb-dev-compat libboost-date-time-dev libboost-filesystem-dev libboost-system-dev libboost-iostreams-dev libpugixml-dev libcrypto++-dev zlib1g-dev

RUN cd /home/3777/src && chmod +x autogen.sh build.sh && ./autogen.sh && ./configure --enable-sqlite --enable-mysql --enable-root-permission --enable-server-diag && ./build.sh && mv theforgottenserver ../tfs
 
Last edited:
Solution
If anyone need to run fir3elemental/3777 on new debian/ubuntu here is updated version:
Changelog to make it compile on Ubuntu 20.04:
AMAZING! with your changes i could compile the 0.4 on my debian 11 <3
Windows docker btw:

I could run it inside a docker container but...
I couldnt find a way to connect to the server after the character list, binding to 0.0.0.0 didn't work with tfs 0.4 at least
and external ip wouldnt work either inside docker so I think it's a dead end :S

EDIT: couldn't find a way to bind the external ip using docker, I dunno much about docker on windows network internals
but default windows wsl2 ran just fine using port forward (netsh interface)
fun to test the server on windows without having the trouble to compile for windows (could never make a successful tfs 0.4 build for x64 on windows)

I still curious about how to run it on docker and use my localhost database
is it possible?
i found that docker create another network:
Code:
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:e1:37:cc:29  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

i mean, i think i don't need it anymore (@Gesior.pl made it work on debian 11) but i still curious to know if it is possible and how to do
 
Back
Top