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

Fix Docker for pyzmq #2167

Closed

Conversation

s-martin
Copy link
Collaborator

g++ was missing to create pyzmq.

This happened to me under Windows

@s-martin s-martin requested a review from pabera December 17, 2023 23:20
@s-martin s-martin added bug future3 Relates to future3 development labels Dec 17, 2023
docker/jukebox.Dockerfile Outdated Show resolved Hide resolved
docker/jukebox.Dockerfile Outdated Show resolved Hide resolved
docker/jukebox.Dockerfile Outdated Show resolved Hide resolved
@s-martin
Copy link
Collaborator Author

Building the container works now, but #1838 still doesn't work.

@s-martin s-martin marked this pull request as ready for review December 20, 2023 21:59
Copy link
Collaborator

@Groovylein Groovylein left a comment

Choose a reason for hiding this comment

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

Worked for me on Linux as well

Copy link
Collaborator

@Groovylein Groovylein left a comment

Choose a reason for hiding this comment

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

OK the build works, but staring throws an error:

mpd exited with code 0
mpd      | exception: Failed to open '/home/pi/.config/mpd/mpd.conf': No such file or directory
[...]
jukebox  | run_jukebox.py: error: argument -c/--conf: can't open '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml': [Errno 2] No such file or directory: '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml'

@AlvinSchiller
Copy link
Collaborator

OK the build works, but staring throws an error:

mpd exited with code 0
mpd      | exception: Failed to open '/home/pi/.config/mpd/mpd.conf': No such file or directory
[...]
jukebox  | run_jukebox.py: error: argument -c/--conf: can't open '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml': [Errno 2] No such file or directory: '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml'

Did you copy the yaml? docker.md#prerequisites

@Groovylein
Copy link
Collaborator

Groovylein commented Dec 21, 2023

OK the build works, but staring throws an error:

mpd exited with code 0
mpd      | exception: Failed to open '/home/pi/.config/mpd/mpd.conf': No such file or directory
[...]
jukebox  | run_jukebox.py: error: argument -c/--conf: can't open '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml': [Errno 2] No such file or directory: '/home/pi/RPi-Jukebox-RFID/shared/settings/jukebox.yaml'

Did you copy the yaml? docker.md#prerequisites

Yes, everything is there.

Changing these volume paths to /home/pi let's the jukebox start:
https://github.com/s-martin/RPi-Jukebox-RFID/blob/42c2e8db97d98599e153cb76763edd3891e5368d/docker/docker-compose.yml#L42

The same applies for mpd:
https://github.com/s-martin/RPi-Jukebox-RFID/blob/42c2e8db97d98599e153cb76763edd3891e5368d/docker/docker-compose.yml#L17

@AlvinSchiller
Copy link
Collaborator

The same applies for mpd:
https://github.com/s-martin/RPi-Jukebox-RFID/blob/42c2e8db97d98599e153cb76763edd3891e5368d/docker/docker-compose.yml#L17

Shouldn't they be overwritten from *linux.yml (but i really know docker compose)? Looks like- ../src/jukebox:xxx is missing here?

docker/docker-compose.linux.yml Outdated Show resolved Hide resolved
docker/docker-compose.linux.yml Outdated Show resolved Hide resolved
docker/jukebox.Dockerfile Outdated Show resolved Hide resolved
@s-martin
Copy link
Collaborator Author

@s-martin
Copy link
Collaborator Author

I got the webapp running under a Github Codespace using Ubuntu.
So I guess my issues on Windows are Windows-related

@s-martin
Copy link
Collaborator Author

s-martin commented Jan 2, 2024

Todo: check pyzmq and libzmq version on a working raspberry instance

@Groovylein
Copy link
Collaborator

My problem now is that I still get the errors:

jukebox  | 22.01.2024 20:32:31 -   67:server.py          - jb.rpc.server        - MainThread      - INFO     - Init RPC Server (Pyzmq version: 21.0.2; ZMQ version: 4.3.3; has draft API: False)
jukebox  | 22.01.2024 20:32:31 -   75:server.py          - jb.rpc.server        - MainThread      - DEBUG    - Connected to address 'inproc://JukeBoxRpcServer'
jukebox  | 22.01.2024 20:32:31 -   81:server.py          - jb.rpc.server        - MainThread      - DEBUG    - Connected to address 'tcp://*:5555'
jukebox  | Traceback (most recent call last):
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/run_jukebox.py", line 67, in <module>
jukebox  |     main()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/run_jukebox.py", line 63, in main
jukebox  |     myjukebox.run()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/jukebox/daemon.py", line 227, in run
jukebox  |     self.rpc_server = RpcServer()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/jukebox/rpc/server.py", line 86, in __init__
jukebox  |     self.socket.bind(websocket_address)
jukebox  |   File "/root/RPi-Jukebox-RFID/.venv/lib/python3.9/site-packages/zmq/sugar/socket.py", line 172, in bind
jukebox  |     super().bind(addr)
jukebox  |   File "zmq/backend/cython/socket.pyx", line 540, in zmq.backend.cython.socket.Socket.bind
jukebox  |   File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
jukebox  | zmq.error.ZMQError: Protocol not supported
jukebox  | 22.01.2024 20:32:31 -   31:daemon.py          - jb.daemon            - MainThread      - DEBUG    - Active Threads = [<_MainThread(MainThread, stopped 139642232436544)>, <Thread(PlayerEventLoop, started daemon 139642181654272)>, <MultiTimer(host.timer.cputemp, started daemon 139642154718976)>]
jukebox exited with code 0

@Groovylein
Copy link
Collaborator

When having one line:
RUN export ZMQ_PREFIX=${PREFIX} && export ZMQ_DRAFT_API=1 && pip install -v --no-binary pyzmq --pre pyzmq

I get another error:

jukebox  | 22.01.2024 21:27:48 -   67:server.py          - jb.rpc.server        - MainThread      - INFO     - Init RPC Server (Pyzmq version: 25.1.2; ZMQ version: 4.3.4; has draft API: True)
jukebox  | 22.01.2024 21:27:48 -   75:server.py          - jb.rpc.server        - MainThread      - DEBUG    - Connected to address 'inproc://JukeBoxRpcServer'
jukebox  | 22.01.2024 21:27:48 -   81:server.py          - jb.rpc.server        - MainThread      - DEBUG    - Connected to address 'tcp://*:5555'
jukebox  | Traceback (most recent call last):
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/run_jukebox.py", line 67, in <module>
jukebox  |     main()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/run_jukebox.py", line 63, in main
jukebox  |     myjukebox.run()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/jukebox/daemon.py", line 227, in run
jukebox  |     self.rpc_server = RpcServer()
jukebox  |   File "/root/RPi-Jukebox-RFID/src/jukebox/jukebox/rpc/server.py", line 86, in __init__
jukebox  |     self.socket.bind(websocket_address)
jukebox  |   File "/root/RPi-Jukebox-RFID/.venv/lib/python3.9/site-packages/zmq/sugar/socket.py", line 302, in bind
jukebox  |     super().bind(addr)
jukebox  |   File "zmq/backend/cython/socket.pyx", line 564, in zmq.backend.cython.socket.Socket.bind
jukebox  |   File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
jukebox  | zmq.error.ZMQError: Protocol not supported (addr='ws://*:5556')
jukebox  | 22.01.2024 21:27:48 -   31:daemon.py          - jb.daemon            - MainThread      - DEBUG    - Active Threads = [<_MainThread(MainThread, stopped 140644536080192)>, <Thread(PlayerEventLoop, started daemon 140644485297920)>, <MultiTimer(host.timer.cputemp, started daemon 140644391253760)>]
jukebox exited with code 1

@s-martin s-martin modified the milestones: v3.5, v3.6 Jan 29, 2024
@pabera pabera mentioned this pull request Feb 5, 2024
2 tasks
@AlvinSchiller AlvinSchiller mentioned this pull request Feb 14, 2024
@s-martin
Copy link
Collaborator Author

#2268 may be related

@s-martin
Copy link
Collaborator Author

Lots of comments here now. :-D
But with the latest changes it seems to work on Windows itself and Linux (WSL Ubuntu).

@AlvinSchiller @pabera @Groovylein if anyone of you could also check, would be nice.

@AlvinSchiller
Copy link
Collaborator

AlvinSchiller commented Feb 19, 2024

Did we change anything for this part? Or is it maybe also the prerelease of pyzmq which makes a change?
Could you test it without the --pre?

Nevermind, didn't see the last commit

@pabera
Copy link
Collaborator

pabera commented Feb 20, 2024

This is not entirely fixed. On my Windows machine, it even doesn't work with the updated pip command. Reason for this is that the downloaded, pre-compiled libzmq does not work on my system (x86_64), even though I used the same machine to compile it before. When I compile libzmq manually in the Dockerfile, it works.

This means, we need to enable a way to build libzmq locally in order to use it in case the pre-built versions do not work.

I am working on that.

@AlvinSchiller
Copy link
Collaborator

AlvinSchiller commented Feb 20, 2024

Could we use the bundled libzmq for that (ZMQ_PREFIX="bundled") ? No further setup of libzmq would be needed if it works.

@pabera
Copy link
Collaborator

pabera commented Feb 21, 2024

Not sure. In my environment, the problem is that pyzmq (actually g++) cannot compile the lib properly and fails. It then falls back on the bundled, none-draft version that pyzmq is shipped with.

@AlvinSchiller
Copy link
Collaborator

Ah ok.
Maybe settings the libzmq version explicitly could help in a first step -> export PYZMQ_LIBZMQ_VERSION=4.3.5

Or turn off the fallback? -> export PYZMQ_NO_BUNDLE=ON

@AlvinSchiller
Copy link
Collaborator

Might be the cause for the problems here aswell? #2302

@pabera pabera self-assigned this Mar 21, 2024
@pabera
Copy link
Collaborator

pabera commented Mar 21, 2024

Pre-building the libzmq does not work well as many users have different host architectures and OS.
The goal should be to build an individual Docker image that just builds libzmq for the host it's running on (1-time build)
Once built, it can be used in docker-compose instead of downloading the pre-built version from our repos.

I am working on this in a branch, but haven't had the time to bring it to a draft.

@notapirate
Copy link
Contributor

notapirate commented Mar 24, 2024

In commit 1ae54c7 changes where made to adjust docker/docker-compose.linux.yaml to docker/docker-compose.mac.yaml. IMHO this doesn't work because other than on mac or windows, on a linux host the already running pulseaudio is used, but for that to work, the UID within the docker container must match the UID of the user outside the container, which doesn't work anymore with 1ae54c7, so I vote to undo that commit.

My docker tests show that based on current branch future3/develop, 2 things need to be changed to make it work again:

  1. In jukebox.Dockerfile move the commands to untar libzmq up to the area before the User is changed, because on a linux-based host this user is limited and can't write to /usr/local.
  2. As @pabera already noted on Feb 20 (I created a separate issue, 🐛 | docker: prebuild libzmq incompatible with debian-bullseye #2302), the prebuilt libzmq doesn't work on x86_64 on bullseye. For testing, one can use the debian:bookworm-slim image for jukebox (netcat package also needs to change to netcat-openbsd) and see if pyzmq works. This might cause other problems (see Sharing tips for future3 on bookworm/kernel 6.6 and upstreaming fixes #2295 for a summary of bookworm experiences), but it should show if the pyzmq problem is solved then.

On my local build I did both changes and it works fine.

@s-martin
Copy link
Collaborator Author

Will check this :)

@s-martin s-martin removed this from the v3.6 milestone Mar 26, 2024
@pabera
Copy link
Collaborator

pabera commented Mar 26, 2024

@s-martin Could you check if the pyzmq problem is solved for you too? This issue has been the reason I provided #2307 :-)

@s-martin s-martin closed this Mar 26, 2024
@s-martin
Copy link
Collaborator Author

#2307 provides a working solution

@s-martin s-martin deleted the future3/fix-docker-windows branch April 7, 2024 18:49
@pabera pabera added this to the v3.6 milestone Apr 8, 2024
@s-martin s-martin removed this from the v3.6 milestone Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug future3 Relates to future3 development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants