brain-monitor icon indicating copy to clipboard operation
brain-monitor copied to clipboard

Adding docker to brain-monitor

Open titusfx opened this issue 5 years ago • 8 comments

This is throwing an Error Width must be multiple of 2. But I'm not able to create a develop branch and a feature branch so you can test it before merge. You need to have docker, and docker-compose in order to use those files. With a simple docker-compose up should work this first version.

titusfx avatar Mar 16 '19 09:03 titusfx

I get an error called invalid ELF header when I do a docker-compose up. I think it needs further investigation. Does it work on your local machine, though?

dashersw avatar Mar 23 '19 17:03 dashersw

I also didn't get a Width must be multiple of 2 error 🤔

dashersw avatar Mar 23 '19 17:03 dashersw

OK, there are a couple of issues — you shouldn't be mounting the whole folder under /app because that will also mount any locally installed npm packages under node_modules. When I remove node_modules and stop mounting the volume, I can get to the Error: Width must be multiple of 2! part.

I don't know what the goal of this development is, though. brain-monitor requires a screen to function — it prints the brainwaves on the screen. It doesn't make much sense to run it inside a docker container.

dashersw avatar Mar 23 '19 17:03 dashersw

The goal is to run your core lib on a docker ( not only brain-monitor), but that also implies that doesn't matter where I'm deploying it, it will deploy well. And you will never get OS problems again. For instance, your readme is for Mac OS only.

Brain-monitor sends the data to a console and you can see it inside the docker without any problem. In any case, you can mount devices on a docker. In fact, the headset will be on it as well.

About how to mount node modules, it depends. In any case, I'm trying to deploy it without errors first and then get a fine solution.

titusfx avatar Mar 26 '19 19:03 titusfx

The core lib is wits, and it actually works in Docker with your example. brain-monitor requires a tty that has a width, it's not simply a console.log — that's why it doesn't work and you get the error Width must be multiple of 2.

If you replace the contents of index.js with

const mind = require('wits')
mind.open()
mind.read(console.log)

you will see that it will work.

dashersw avatar Mar 26 '19 23:03 dashersw

Also, mounting node_modules doesn't depend on anything, it simply doesn't work. When you do an npm install on wits or any project that has wits as a dependency, it will compile native C modules. The output of the compilation will be different on Mac and Linux.

Say, you have a Mac, you clone the project, and do npm install. Later, you run docker-compose up, which, as in your example, mounts the node_modules folder. In this case, you will get an error that says Error: /app/node_modules/wits/build/Release/emotiv.node: invalid ELF header. This is because the docker image expects Linux binaries under node_modules, but because we ran npm install on Mac, the binaries are Mac-specific.

That's why you can't mount a Mac-compiled node_modules to a Linux docker image.

dashersw avatar Mar 26 '19 23:03 dashersw

Its depends, sure that what you are saying is important, because we need to run first on the docker so the installation of npm will compile native C module. But this doesn't make any difference if you later want to install something or checkout something that you have access to. For developing purposes is think is easier for the CI.

For the gui is simple to associate. My First initative is with your core lib, and if you are saying that is working, that's great news.

In any case, for making brain monitor show a screen could be made as well. This could be one way: http://wiki.ros.org/docker/Tutorials/GUI

titusfx avatar Mar 30 '19 19:03 titusfx

indeed, wits is working inside Docker (provided that one can attach the USB).

dashersw avatar Apr 07 '19 19:04 dashersw