simojenki / bonob

sonos SMAPI implementation allowing integrating different music sources with sonos.
GNU General Public License v3.0
219 stars 15 forks source link

Docker commands not working and no error/log output #92

Closed jat255 closed 2 years ago

jat255 commented 2 years ago

Hi there, I was trying out bonob to connect to my navidrome instance, and I'm running the following:

$ docker run -e BNB_SONOS_AUTO_REGISTER=true -e BNB_SONOS_DEVICE_DISCOVERY=true -p 3000:3000 -e BNB_PORT=3000 -e BNB_SONOS_SEED_HOST=<my sonos device IP> simojenki/bonob

When I run that command, I get zero output, so I'm not even sure where to start debugging... I tried the same command with a few other tags (v0.6.0 and v0.5.0) and get the same result. I've confirmed I can run $ docker run hello-world and get the expected response, so I don't think it's an issue with my Docker. Any thoughts?

Looking at the output of docker container list --all, it looks like they're exiting with exit code 132:

CONTAINER ID   IMAGE                    COMMAND                  CREATED              STATUS                            PORTS     NAMES
3f58a3e1ecd0   simojenki/bonob          "docker-entrypoint.s…"   13 seconds ago       Exited (132) 10 seconds ago                 suspicious_yalow
2e73651cba24   simojenki/bonob:v0.5.0   "docker-entrypoint.s…"   About a minute ago   Exited (132) About a minute ago             quirky_ride
16cde7e80c99   simojenki/bonob          "docker-entrypoint.s…"   5 minutes ago        Exited (132) 5 minutes ago                  lucid_edison
e06e7307b4ef   hello-world              "/hello"                 5 minutes ago        Exited (0) 5 minutes ago                    gallant_sammet
jat255 commented 2 years ago

Hmm, so even building the docker image manually is failing on the yarn test step with exit code 129

jat255 commented 2 years ago

I tried commenting out the test line, and the image would build, but same issue as before: no output at all and exit code 132. Not sure what's going on...

simojenki commented 2 years ago

mmm, sounds like something with your setup. I ran the following;

docker run -e BNB_SONOS_AUTO_REGISTER=true -e BNB_SONOS_DEVICE_DISCOVERY=true -p 3000:3000 -e BNB_PORT=3000 -e BNB_SONOS_SEED_HOST=192.168.1.222 simojenki/bonob

The first thing the app does is determine the config and then log the following line;

{"message":"Starting bonob with config {\"port\":3000,.................

So the fact it cannot even do that much is odd.

The tests should work, they are run multiple times on each commit, once before any image building, and once as part of building the 3 supported platforms as part of docker build.

What kind of machine are you trying this on? Does it have enough free RAM?

jat255 commented 2 years ago

Hmm, okay at least I know it's just me! This is in a lightweight container (Proxmox), so perhaps it's a memory issue. I ruled out disk space and # of vCPUs, but I'll try debugging a bit more and report back.

jat255 commented 2 years ago

The container has 2 GB RAM and doesn't seem to run out when trying to run, so I'm not sure what's going on. I'm going to try to run it on "bare metal" inside the container rather than through Docker and see if that makes a different (I know, Docker inside a container is silly, but it generally works...)

jat255 commented 2 years ago

Huh, when trying to run on this system after installing following the Dockerfile instructions, I got the following:

$ node app.js
[1]    29168 illegal hardware instruction  node app.js

Seems like something incompatible, although I haven't had issues with this setup in the past (running things inside a Debian LXC container on Proxmox, which is basically Debian)

jat255 commented 2 years ago

Tracked this down to const sharp_1 = __importDefault(require("sharp")); in server.js (after building with yarn), and some googling pointed me to https://github.com/lovell/sharp/issues/1437

simojenki commented 2 years ago

Is your proxmox host arm based? Or amd64?

jat255 commented 2 years ago

Is your proxmox host arm based? Or amd64?

Definitely amd64:

# lscpu 
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          2
simojenki commented 2 years ago

The issue that you found on Google refers to sharp not working on raspberry Pi which is arm based. I use amd64, the amd64 image with sharp is fine. Are you sure that your server is not trying to run an arm image for some reason?

jat255 commented 2 years ago

Yeah, it's really odd and I don't understand why it's not working, unless yarn is pulling in the wrong version of a package for some reason? Thanks for the help and sorry for the noise. The container is definitely an amd64-based Debian, and installing via "bare metal" shouldn't be using any Docker images or binaries compiled for arm. The only thing I can think of based on what I see in that linked issue is perhaps some incompatibility between the system-installed libvips and the sharp package, but I have no idea. I'll keep poking at it to see if I can get it working.

jat255 commented 2 years ago

Huh, I'm stumped. I just tried running the original docker command in an Ubuntu 20.04.3 VM on this system (so fully isolated from the host), and I got the same thing: no output and a 132 exit code. I even tried creating a debian container from scratch and doing the full install of node and everything, and got the same "Illegal instruction" as before. Something about this package doesn't like me or my hardware, that's for sure. Thanks for your help, but I think I'm going to give up at this point!

simojenki commented 2 years ago

That is very strange indeed. I develop this on an Ubuntu machine (AMD64), and the Dockerfile builds on each commit...

jat255 commented 1 year ago

Circling back around on this, after doing some more research I think the above is probably due to the fact that I am running my Proxmox server on some pretty old AMD hardware. I suspect it has something to do with this: https://github.com/lovell/sharp/issues/3030

Either way, I tried again using an Arch Linux LXC, and was able to get Bonob running. In case anyone is struggling with this, here was what I did (after installing nvm via the AUR). I suspect the libvips issue compiles with some optional flag that doesn't trigger the error on my system.

Installing bonob on Arch Linux:

$ nvm install 16
$ git clone https://github.com/simojenki/bonob.git /home/user/bonob
$ cd /home/user/bonob
$ sudo pacman -S libvips lcms2 openjpeg2 libheif libjxl openslide poppler-glib imagemagick tzdata
$ npm install -g yarn
$ yarn config set network-timeout 600000 -g
$ yarn install \
        --prefer-offline \
        --frozen-lockfile \
        --non-interactive \
        --production=false
$ yarn test --no-cache    # this had a couple failing tests in clock.test.ts, but the rest succeeded...
$ yarn gitinfo
$ yarn build
$ rm -rf node_modules
$ NODE_ENV=production yarn install \
        --prefer-offline \
        --pure-lockfile \
        --non-interactive \
        --production=true
$ cp -r web build/
$ cp -r src/Sonoswsdl-1.19.4-20190411.142401-3.wsdl build/src/

# actually run bonob:
$ node build/src/app.js
u8915055 commented 8 months ago

THank you @jat255 for doing this. I am just building it now. I did notice one warning that popped up:

warning " > soap@1.0.0" has incorrect peer dependency "axios@^0.27.2". 

However it seems to build and run. Again thanks very much.

u8915055 commented 8 months ago

For anyone who does it, here is my systemd file to start this up.

[Unit]
Description=Bonob Sonos daemon
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
User=bonob
Group=wheel
Type=simple
RemainAfterExit=yes
Environment=BNB_URL=http://192.168.1.25:4534
Environment=BNB_SUBSONIC_URL=http://192.168.1.18:4533
Environment=BNB_SUBSONIC_CUSTOM_CLIENTS=audio/flac
Environment=BNB_SONOS_AUTO_REGISTER=true
Environment=BNB_SONOS_DEVICE_DISCOVERY=true
Environment=BNB_SONOS_SERVICE_NAME=Navidrome
TZ: America/Vancouver
ExecStart=/home/bonob/.nvm/versions/node/v16.20.2/bin/node app.js
WorkingDirectory=/home/bonob/bonob/build/src
TimeoutStopSec=20
KillMode=process
Restart=on-failure

Just place in /etc/systemd/system and enable it and start it. .Make sure the user and group make sense for you. I created a user 'bonob' and put that user in group 'wheel'. Works like a champ. This piece of software is pure magic! Thanks again for the work on this. Now have this running nicely in a LXC on proxmox with navidrome running in another LXC.