Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile to use Python base image and add input args #7579

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

jutoft
Copy link
Contributor

@jutoft jutoft commented Aug 19, 2023

Uses Python base image & add more input args to allow changing the mount directory.

input to the handling of input arguments is much appreciated

Fixes #7563, #7560

@jutoft jutoft requested review from a team and drew2a and removed request for a team August 19, 2023 12:44
@drew2a drew2a requested a review from xoriole September 4, 2023 12:30
@drew2a
Copy link
Contributor

drew2a commented Sep 4, 2023

@jutoft, thank you for your contribution. I'll be reviewing the PR shortly.

@xoriole, would you be able to review the Docker-related portion of this PR, please?
@jutoft, could you kindly address the issues flagged by Codacy?"

drew2a
drew2a previously requested changes Oct 5, 2023
Copy link
Contributor

@drew2a drew2a left a comment

Choose a reason for hiding this comment

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

I've reviewed the Python portion of the PR and it seems to be a nice improvement. Thank you!

I've left a few minor comments.
Codacy issues should be addressed.

src/run_tribler_headless.py Outdated Show resolved Hide resolved
src/run_tribler_headless.py Outdated Show resolved Hide resolved
@drew2a
Copy link
Contributor

drew2a commented Oct 31, 2023

@xoriole, could you please review the Docker-related part of this PR?

@drew2a drew2a self-requested a review October 31, 2023 09:13
Dockerfile Outdated Show resolved Hide resolved
src/run_tribler_headless.py Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
@xoriole
Copy link
Contributor

xoriole commented Nov 9, 2023

Running the built docker image, I'm getting the following error. This might not be the result of this PR but would need to be investigated further

WARNING: Published ports are discarded when using host network mode
INFO:Tribler Config:Load: /state/triblerd.conf. State dir: /state. Reset config on error: False
INFO:Tribler Config:Init. State dir: None. File: None
ERROR:tribler.core.utilities.process_manager.manager:OperationalError: unable to open database file
Traceback (most recent call last):
  File "/app/tribler/src/tribler/core/utilities/process_manager/manager.py", line 62, in connect
    self.connection = connection = sqlite3.connect(str(self.db_filepath))
sqlite3.OperationalError: unable to open database file
WARNING:tribler.core.utilities.process_manager.manager:Retrying after the error: OperationalError: unable to open database file
ERROR:tribler.core.utilities.process_manager.manager:OperationalError: unable to open database file
Traceback (most recent call last):
  File "/app/tribler/src/tribler/core/utilities/process_manager/utils.py", line 29, in new_method
    return method(self, *args, **kwargs)
  File "/app/tribler/src/tribler/core/utilities/process_manager/process.py", line 150, in become_primary
    with self.manager.connect():
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/app/tribler/src/tribler/core/utilities/process_manager/manager.py", line 62, in connect
    self.connection = connection = sqlite3.connect(str(self.db_filepath))
sqlite3.OperationalError: unable to open database file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/tribler/src/tribler/core/utilities/process_manager/manager.py", line 62, in connect
    self.connection = connection = sqlite3.connect(str(self.db_filepath))
sqlite3.OperationalError: unable to open database file
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-1' coro=<TriblerService.start_tribler() done, defined at /app/tribler/src/run_tribler_headless.py:58> exception=OperationalError('unable to open database file')>
Traceback (most recent call last):
  File "/app/tribler/src/tribler/core/utilities/process_manager/utils.py", line 29, in new_method
    return method(self, *args, **kwargs)
  File "/app/tribler/src/tribler/core/utilities/process_manager/process.py", line 150, in become_primary
    with self.manager.connect():
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/app/tribler/src/tribler/core/utilities/process_manager/manager.py", line 62, in connect
    self.connection = connection = sqlite3.connect(str(self.db_filepath))
sqlite3.OperationalError: unable to open database file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/tribler/src/run_tribler_headless.py", line 85, in start_tribler
    if not self.process_manager.current_process.become_primary():
  File "/app/tribler/src/tribler/core/utilities/process_manager/utils.py", line 32, in new_method
    return method(self, *args, **kwargs)
  File "/app/tribler/src/tribler/core/utilities/process_manager/process.py", line 150, in become_primary
    with self.manager.connect():
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/app/tribler/src/tribler/core/utilities/process_manager/manager.py", line 62, in connect
    self.connection = connection = sqlite3.connect(str(self.db_filepath))
sqlite3.OperationalError: unable to open database file

Next, running the image with docker-compose, it fails with error "host" network_mode is incompatible with port_bindings.

WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

WARNING: Found orphan containers (tribler_metabase_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Recreating triblercore ... 

ERROR: for triblercore  "host" network_mode is incompatible with port_bindings

ERROR: for tribler-core  "host" network_mode is incompatible with port_bindings
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1186, in up
  File "compose/cli/main.py", line 1182, in up
  File "compose/project.py", line 702, in up
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/project.py", line 688, in do
  File "compose/service.py", line 581, in execute_convergence_plan
  File "compose/service.py", line 503, in _execute_convergence_recreate
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/service.py", line 496, in recreate
  File "compose/service.py", line 615, in recreate_container
  File "compose/service.py", line 334, in create_container
  File "compose/service.py", line 941, in _get_container_create_options
  File "compose/service.py", line 1073, in _get_container_host_config
  File "docker/api/container.py", line 598, in create_host_config
  File "docker/types/containers.py", line 339, in __init__
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
[71059] Failed to execute script docker-compose

@jutoft
Copy link
Contributor Author

jutoft commented Nov 12, 2023

@xoriole the issue with the program being unable to open database is probably due to broken permissions.
It's running as user 1000 or something and your user has another id. Thats why i removed the user part of the Dockerfile, it usually is just a nuisanse.
The person running the image should usually assign uid & gid themselves.

I can remove the network mode host or the ports section.
If we switch to bridge mode then a lot more ports need to get mapped i think, so maybe using host is fine?

I pushed a change where ports has been removed.

@drew2a drew2a removed their request for review November 22, 2023 14:46
@drew2a
Copy link
Contributor

drew2a commented Nov 22, 2023

I have removed myself from the list of reviewers, as it gives the impression that the PR is awaiting my review, which I have already provided. From my perspective, the Python changes are acceptable. We are now awaiting a response from @xoriole.

Copy link
Contributor

@xoriole xoriole left a comment

Choose a reason for hiding this comment

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

@jutoft Could you update the run commands in the ReadMe file?
https://github.com/Tribler/tribler/blob/main/README.rst

@jutoft
Copy link
Contributor Author

jutoft commented Dec 8, 2023

@jutoft Could you update the run commands in the ReadMe file? https://github.com/Tribler/tribler/blob/main/README.rst

@xoriole I was wondering why you had the file permission issues and i found it to be "" around the state dir path.
That should be fixed now.

Would you like me to add a section about the command line arguments in general, currently there is'nt really any docs about it.
The current docker & docker-compose commands seem to work fine for me.

jutoft and others added 2 commits February 13, 2024 15:31
…irectory

Fixes Tribler#7563, Tribler#7560

Rename downloaddir to download_dir.

add --no-install-recommends as requested by codacy.

Add direct support for CORE_API_PORT in run_tribler_headless.py

fix version info checkfor win32

set runtime user to be user

fix incorrect environment config and refactor setting http or https enabled.

Remove ports & rely on hosts mode for the docker-compose.yml example file.

Fix " in env property

Add http(s) host as env args on Dockerfile
Update docker compose to include port mapping and http host env var

Add default /state and /downloads for simplified run

Update ReadMe to run docker with volume mounts
Copy link
Contributor

@xoriole xoriole left a comment

Choose a reason for hiding this comment

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

@jutoft Thank you for your contribution 🎉

@xoriole xoriole changed the title Use python base image & add more input args to allow changing mount d… Update Dockerfile to use Python base image and add input args Feb 13, 2024
@xoriole xoriole merged commit 697422c into Tribler:main Feb 13, 2024
20 checks passed
@xoriole xoriole self-assigned this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Update docker image to latest versions
3 participants