wellenvogel / avnav

using the raspberry pi as a nav computer
MIT License
87 stars 27 forks source link

Running in Docker? #269

Open tkurki opened 1 year ago

tkurki commented 1 year ago

I'd like to try Avnav "for real" (with o-charts for Finnish waters) but would like to keep it in Docker, like I have all my other software. Do you think it is feasible?

Docker is mentioned in #179 - did you @emilecantin make any progress with it?

This Dockerfile (based on https://github.com/free-x/avnav-gen-arm64)

FROM debian:bullseye

COPY files .

RUN apt-get update
RUN apt-get install -y python3-bluez \
python3-pyudev \
python3-serial \
python3-gdal \
python3-netifaces \
python3-pil \
python3-pigpio \
gnupg

RUN apt-key add - < ./oss.boating.gpg.key && \
echo 'deb https://www.free-x.de/debian bullseye main contrib non-free' >/etc/apt/sources.list.d/avnav.list && \
echo '#deb https://open-mind.space/repo/ bullseye-stable avnav' >>/etc/apt/sources.list.d/avnav.list && \
echo '#deb https://open-mind.space/repo/ bullseye-daily avnav' >>/etc/apt/sources.list.d/avnav.list && \
apt-get update
RUN apt-get install -y avnav
ENTRYPOINT [ "/usr/bin/avnav" ]

builds and running it gives me a functioning AvNav, at least the osm charts work.

I guess fiddling with the startup & configuration will make the errors go away and then I could connect to my Signal K server for data.

Is o-charts something that is feasible with this setup?

Is this something somebody else might be interested in?

free-x commented 1 year ago

hi @tkurki at first you need to adjust options for start of avnav

Illegal option -h
invalid option ?
usage: /usr/bin/avnav [-e] [-d] [-q] [-b basedir] [-c chartdir] [-x cfgfile] [-t template] [-g] [-a softwareBase] [-v viewerDir]
       -b basedir     : data dir for avanv routes,tracks,charts,...
       -c chartdir    : separate dir for charts (instead of basedir/charts)
       -x cfgfile     :  start the server directly with this config (not for gui)
       -t template    : create basedir/avnav_server.xml from this if not found
       -l loglevel    : set the log level (ERROR|INFO|DEBUG)
       -e             : directly fail on any errors in avnav_server.xml instead of trying avnav_server.xml.ok
       -d             : start with loglevel debug
       -g             : start with GUI instead of normal server mode
       -q             : do not log to stderr
       -n envFile     : read environment variables from env file if it exists
       -------------- some development options --------------
       -a softwareBase: find the server software at this directory
       -v viewerDir   : find the viewer software at this directory

Volume with "data" should be exported

An example of avnav as client of SK can be found at openplotter https://raw.githubusercontent.com/e-sailing/openplotter-avnav/master/openplotterAvnav/data/avnav_server.xml

Indeed o-charts in docker would be most exciting part

greetings free-x

wellenvogel commented 1 year ago

I think it should be possible... Basically everything has defaults and should more or less start to work out of the box. As @free-x already said it would make sense to have the data dir (-b) on a mounted volume - but it depends. Running o-charts should be possible (doing this while developing) - just install the package avnav-ocharts-plugin (it will also install the avnav-ocharts) and the dependencies. The interesting part is the licensing stuff. I would be rather sure that you could create an FPR and get some charts assigned from the shop. Not sure about the dongle. But if having the right privileges for USB devices it could work... Just ensure to have 8080 (AvNav itself) and 8082 (AvNav-ocharts) as ports being mapped (or you need to use the docker network addresses). For o-charts there could be some issue with the network addresses: The plugin checks the client address to be in a local network. So potentially using the docker network finally is the only real chance...

For the SK connectivity: You can easily configure a remote SK host. If you want to "feed" everything from Signalk it should be sufficient to set the correct SK host on the AVNSignalKHandler (Server/Status page), activate "decodeData", "fetchAis". If you want to send back you can activate "sendData". In this case you need to input username/password. If you want you still can configure other connections - but that's not really necessary for this case.

If you have put your data dir to a mounted volume things should be persistent. And if you would like to go for multiple instances - just take your adapted avnav_server.xml, put it into the docker image and use it for the -t parameter - this way starting with it as a template.

tkurki commented 1 year ago

For chart licensing I was thinking about the dongle as the only viable option, I don’t think anything else makes sense. You should be able to recreate Docker containers whenever.

wellenvogel commented 1 year ago

Agree.. So we just have to find out what the dongle needs - not sure if --device will do or if we have to go for some --privileged mode for the container. OK - a quick check shows that oexserverd is accessing /dev/bus/usb/** - so not sure if this will work out of the box.

tkurki commented 1 year ago

Build with avnav-ocharts-plugin fails with this Dockerfile on RPi 3 arm64

#0 10.71 The following packages have unmet dependencies:
#0 11.28  libgtk-3-0 : Depends: libgtk-3-common (>= 3.24.24-4+rpt2) but it is not going to be installed
#0 11.28               Recommends: libgtk-3-bin but it is not going to be installed
#0 11.28               Recommends: librsvg2-common but it is not going to be installed

Ideas?

free-x commented 1 year ago

Hi @tkurki,

libgtk-3-common is a part of Raspbian repository which is not in sources.list in your Docker. I included package yet to my repo. You could try again

Regards free-x

wellenvogel commented 1 year ago

Additional hint: As always - when mapping the data dir from outside - take care of user id / permissions. Basically avnav is able to run with every user. So you could either add a user that has the same id like your host user - or change the userid for avnav...

tkurki commented 1 year ago

Thanks, I'll worry about userid mapping etc once I get both avnav and avnav-ocharts-plugin to install & start.

Not sure how much time I'll have for this in the coming weeks, but at least I have a start that even somebody else could continue if I fall by the wayside...