Quedale / OnvifDeviceManager

Onvif Device Manager for Linux
GNU General Public License v3.0
74 stars 17 forks source link

Implement deployment package (flatpak, snap, AppImage, etc...) #9

Open edurenye opened 10 months ago

edurenye commented 10 months ago

Create a docker file to make the installation more easier

edurenye commented 10 months ago

I thought it was a web UI, sorry.

Well, would be nice to have a web UI

Quedale commented 10 months ago

Related to Issue #10, I'm reopening this issue for tracking.

Quedale commented 10 months ago

Yesterday I manage to successfully create a functional PoC. I just have to refine a few details and should be available soon.

For instance properly mapping ports that would be used by gstreamer for the backchannel.

Unfortunately, achieving this requires modifying the system's display pernission to allow docker to display GUI windows. Since it uses a GTK window, I doubt this would integrate well as a docker plugin like HomeAssitant.

Regardless, the option will be available to offer a simple way to ensure build compatibilty on unexpected platform.

Quedale commented 10 months ago

Last night I published the PoC Dockerfile.

Unfortunately, I was unable to get the microphone to work since my system uses Pulseaudio. This isn't my recommended solution, but should provide some guidance if anyone wish to use it.

simply run docker/docker_build_run.sh

Let me know how that goes!

edurenye commented 9 months ago

The script fails for me on the build, but running manually works, maybe there is a way to move the xhost +Local:* into a docker compose file, would make the instructions more simple and remove the need for that script, or what do you think? From https://gursimarsm.medium.com/run-gui-applications-in-a-docker-container-ca625bad4638 says should just be:

version: "3"
services:
  onvifmgr:
    build: .
    environment:
      - DISPLAY=${DISPLAY}
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    network_mode: host

Why do you need the speaker device mapped?

Quedale commented 9 months ago

I will look into later today if I get a chance. Although after a quick read, I doubt there's a way around xhost configuration.

There's a section entitled Handling X Authentication, which refers to the xauth and xhost utilities. I will read about xauth given that it seems to be a better alternative to xhost.

Regarding speaker/microphone mapping, it isn't mandatory for the tool to work, but it does support bidirectional audio with cameras that also supports it. Without access to the hardware, bidirectional audio support is rendered useless.

The script I wrote doesn't have the bash header, which I suppose might cause issues by invoking the wrong default interpreter. Can you provide additional details about your system, so that I can reproduce a similar environment?

Thanks!

Quedale commented 9 months ago

I had a chance to give it a shot and unfortunately, docker compose doesn't take care of X Authentication.

Not running the xhost command results with the following message:

 ✔ Container onvifmgr_container  Recreated                                                                                                                     0.2s 
Attaching to docker-onvifmgr-1
docker-onvifmgr-1  | Authorization required, but no authorization protocol specified
docker-onvifmgr-1  | 
docker-onvifmgr-1  | (onvifmgr:7): Gtk-WARNING **: 04:35:45.182: cannot open display: :0
docker-onvifmgr-1 exited with code 1

I added the yaml file anyway as an alternative to the script. Thanks for this contribution.

I will dig around xauth and using token instead of xhost.

edurenye commented 9 months ago

I'm running Ubuntu 22.04.3 LTS & Docker version 24.0.6. I guess has something to do with me using zsh, don't nee to worry about that I just run the commands inside the script. The command xhost "+Local:*" works for me if I add the quotes. I wonder if giving access to X server to all applications might have security implications, maybe we shoud use VNC instead. But when I run the docker container I get:

Gtk-Message: Failed to load module "canberra-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
realloc(): invalid next size
Aborted (core dumped)

I haven't found any issue regarding xhost support for docker compose, and also I was wondering if this will work for other operating systems or X servers like Wayland. Maybe VNC is a better solution after all. What do you think?

Quedale commented 9 months ago

From what I understand about Docker, it uses the system's kernel instead of virtualizing it. This could lead to different results depending on the system. What desktop environment are you using? I imagine it should come out-of-the-box for Gnome and KDE desktop.

You are correct regarding X permissions that it involves a few security implications. That's why I think xauth token might be a better approach.

VNC could be an alternative candidate assuming that it doesn't introduce latency. VNC might be viable for most application use-case, but this application involves real-time video stream which could potentially add latency or even loose image quality. I will look into it as well to get familiar with it.

That being said, Docker is most likely not the best fit for what we are trying to achieve here. (Cross-environment deployment)

I honestly didn't look into deployment strategy yet, since I didn't even make an official release. Something like AppImage or Snap might be a better fit for this purpose.

edurenye commented 9 months ago

I'm using Gnome. I agree VNC would add latency so might not be the best solution. I'm not super familiar neither, so I don't know the best way to architecture this.

GrueMaster commented 8 months ago

Out of curiosity, why Docker? Since this is a gui app, why not create a snap and/or flatpak for this? These environments integrate with the system desktop better and make them self-contained for some library dependencies.

Docker is better suited for background services.

edurenye commented 8 months ago

Yes, that would work too, I think snap is more limited, but flatpak would be great.

Quedale commented 6 months ago

I tried docker for s**** and giggles. Turns out it doesn't support GUI application gracefully. I will definitely consider flatpak once I find this project stable enough.

I'm still finding some bugs and improving overall stability.

You can keep this issue open for tracking for whenever I get around to it.

Thanks for this input!