Tribler / tribler

Privacy enhanced BitTorrent client with P2P content discovery
https://www.tribler.org
GNU General Public License v3.0
4.74k stars 445 forks source link

Run tribler in docker as a web application with a gui #6759

Open dmuiX opened 2 years ago

dmuiX commented 2 years ago

Dear devs,

Nice application so far. Would be so nice if you could run this application as a web service in docker with a web gui. I want to use it on my home server. And with a web application I could use it from every device I have and let the downloads run over night. Way easier than running it locally on my notebook.

Thanks and kind regards

Daniel

dmuiX commented 2 years ago

Okay looks like somebody has already written this enhancement in another issue. Might be good to make the suggestions there more invisible so new users like me find it when lookin on Google for tribler docker.

kotenok2000 commented 2 years ago

Maybe you meant visible?

dmuiX commented 2 years ago

Yeah visible of Course :D

devos50 commented 2 years ago

Thank you for your suggestion!

mivale commented 1 year ago

After some fiddling I've got this working in a rudimentary fashion.

I've had to make some tweaks to the Dockerfile to get the Qt version to work, then I created another Dockerfile, which is basically a Xvfb / X11Vnc wrapper around the first image, which has all the correct librararies installed.

When I finally had it working, it turned out that api_port was not an int but a string, so not being a python guy myself, I just hacked this away:

diff --git a/src/tribler/gui/tribler_window.py b/src/tribler/gui/tribler_window.py
index 0e6b84730..3c53e1c49 100644
--- a/src/tribler/gui/tribler_window.py
+++ b/src/tribler/gui/tribler_window.py
@@ -177,6 +177,7 @@ class TriblerWindow(QMainWindow):
         api_port = api_port or default_network_utils.get_first_free_port(
             start=int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT))
         )
+        api_port = int(api_port)
         if not default_network_utils.is_port_free(api_port):
             raise RuntimeError(
                 "Tribler configuration conflicts with the current OS state: "

Then you need a simple start script which fires up xvfb / fluxbox / x11vnc / tribler (in said order) - never mind the sleeps

# Do not use 32bpp
export DISPLAYSIZE="1280x900x24"

# login with this password
export VNCPASSWORD="tribler"

export DISPLAY=:1

/usr/bin/Xvfb $DISPLAY -screen 0 "$DISPLAYSIZE" &

/usr/bin/fluxbox >/dev/null &

sleep 5
x11vnc -display $DISPLAY -bg -forever -usepw -passwd "$VNCPASSWORD" -shared -forever &

sleep 5
/tribler/src/tribler.sh

After the container has been started (mind you, this image is only local)

docker run --rm -d \
  -v $(pwd)/settings:/home/user/.Tribler \
  -v $(pwd)/download:/home/user/Downloads \
  -p 5900:5900 mivale/tribler-vnc:latest

you've got a gui version of tribler accessible via vnc running on any linux machine.

Caveat: the resulting docker image is 2.79GB and I have NOT tried downloading anything with it (it's currently not running in host mode, don't know if that's a must)

image

Notice the macos vncviewer artifacts 🤣

Let me know if anyone has interest in this and wether or not to create a pull request. You could build everything in a single container using a git clone off main (with the single int() tweak, that is).

It would be nice if someone else also were to test this 😬

Perhaps it would be better to just create a repo which does all the heavy work and leaves Tribler alone 😝

allenyllee commented 1 year ago

Just curious, can we separate frontend from backend? For example, run a backend inside a server container, and run a GUI frontend through a client container?

mivale commented 1 year ago

Glad you asked that, because that was my first thought as well, and also my first try.

Technically it must be possible but when I tried to make the gui talk to another backend on a different container by claiming the api port and forwarding it, the gui (at least on mac) spawned its own api on the next port and started talking to that one.

A setting with a backend url would make this possible. I have a feeling the api/gui combo are hardwired together.

febriansasi commented 3 months ago

Is there any update how to run tribler on docker