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

Raspberry Pi support for the docker image #73

Open
osos opened this issue Aug 28, 2020 · 34 comments · May be fixed by #84
Open

Raspberry Pi support for the docker image #73

osos opened this issue Aug 28, 2020 · 34 comments · May be fixed by #84
Labels
ci Continuous integration/build enhancement New feature or request

Comments

@osos
Copy link

osos commented Aug 28, 2020

Is your feature request related to a problem? Please describe.
Yes. the docker image does not run on raspberry pi

Describe the solution you'd like
Would like a docker image compiled for arm to enable the use of this brilliant bridge on the raspberries. This would in turn enable ll users of Home Assistent and other DIY setups to benefit from your work.

@osos osos added the enhancement New feature or request label Aug 28, 2020
@osos
Copy link
Author

osos commented Aug 28, 2020

This info might be helpful: https://gist.github.com/neilyoung/8216c6cf0c7b69e25a152fde1c022a5d

@shortcircuit412
Copy link

same issue here, docker image for raspberry on wishlist. I am going to look at errors now and will post additional intel later.

@osos
Copy link
Author

osos commented Aug 29, 2020

So far it seems the docker image is based an a pure amd64 image:

https://hub.docker.com/_/rust?tab=tags

Maybe base the Dockerfile image on rust:slim instead of rust:1-alpine. Basically all the rust:alpine are amd64 only.

Of course then the Dockerfile need to install using apt-get and not apk, but that should be doable.

@osos
Copy link
Author

osos commented Aug 29, 2020

Best guess on dependencies (tried on raspbian, but unfortunately my raspberry shuts down due to overheat during compiling):

  • apt-get install gstreamer1.0-rtsp libgstrtspserver-1.0-dev libgstrtspserver-1.0 musl

To compile on rasbian the rust / cargo should be installed using the installer script https://www.rust-lang.org/tools/install as the rep-version is to old. For the dockerfile it should not be necessary as included in the rust:slim image

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Aug 31, 2020

Is there any reason you want a docker rather than using the armhf binary?

I use this on my own raspberry pi to bridge to HA without docker, I am not sure why you want to add this as it will put more load onto your pi if you run through docker rather than directly

@QuantumEntangledAndy
Copy link
Collaborator

Try something like this

  1. Install dependencies
sudo apt install \
  libgstrtspserver-1.0-0 \
  libgstreamer1.0-0 \
  libgstreamer-plugins-bad1.0-0 \
  libgstreamer-plugins-good1.0-0 \
  gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-bad
  1. Get binary from here

  2. Extract it and then put neolink in /usr/local/bin/

  3. Get the sample conf from here

  4. Adapt sample config and make it work for your cameras

  5. Put sample config in /usr/local/etc/neolink_conf.toml


Optional steps to make a service (useful for HA) and keep it running in the background

  1. Make the user and group to run as a service
sudo adduser --system --no-create-home --shell /bin/false neolinker
sudo addgroup --system neolinker
  1. Create a service file at /etc/systemd/system/neolink.service with the following contents
[Install]
WantedBy=multi-user.target

[Unit]
Description=Neolink service

[Service]
Type=simple
ExecStart=/usr/local/bin/neolink --config /usr/local/etc/neolink_config.toml
Restart=on-failure
User=neolinker
Group=neolinker
  1. Enable service at startup
sudo systemctl enable neolink
  1. Run neolink through the service controls
sudo service neolink start

@osos
Copy link
Author

osos commented Aug 31, 2020

Thank you for the pointers.

docker support for the raspberries are preferable due to lots of other "iot" pckages are supported that way and makes it easier on the noob users. We use it often with the IOTStack (https://github.com/SensorsIot/IOTstack). The docker images makes it very easy to setup and test with low to none impact on main-system.

@QuantumEntangledAndy
Copy link
Collaborator

I see, well currently we cross compile the armhf build. So we build it on amd64 for armhf.

I do not know if we can make an image without access to an armhf machine to build it.

We did do some testing using debian:buster at some point and the last debian build is docker pull quantumentangledandy/neolink:deb_stable but I think you will need more than that to get it to work. It really is not too hard to make a buster docker build of neolink. But the issue comes with making a buster armhf docker, if you know how to do that part let me know

@osos
Copy link
Author

osos commented Aug 31, 2020

I have not tested any of this. But a few pointers:

@QuantumEntangledAndy
Copy link
Collaborator

Both cases seem to be done using QEMU, do you think you could work up a PR? The rust armv7 docker seems to be here and the build dependencies are

sudo apt-get install --assume-yes --no-install-recommends \
          libgstrtspserver-1.0-dev \
          libgstreamer1.0-dev \
          libgtk2.0-dev

With runtime dependencies of

sudo apt install \
  libgstrtspserver-1.0-0 \
  libgstreamer1.0-0 \
  libgstreamer-plugins-bad1.0-0 \
  libgstreamer-plugins-good1.0-0 \
  gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-bad

There's more info on getting QEMU to work here

@QuantumEntangledAndy
Copy link
Collaborator

@osos I have been experimenting with a multiarch docker image here:

docker pull quantumentangledandy/neolink:rpi-docker-debian

Could you tell me if it is working?

@QuantumEntangledAndy
Copy link
Collaborator

I have been testing on my own rpi and its not quite ready yet but almost got it working :)

@osos
Copy link
Author

osos commented Sep 20, 2020

Thank you for the great efforts. I have succeed to sell both my D800 - and, thus, I am unable test neolink on them going forward.

I still think it is very much worth it to get this working in docker on Rpi.

@QuantumEntangledAndy
Copy link
Collaborator

I actually have a working cross compiled docker image for raspberry pi. What I am trying now is to make a multiarch image that supports amd64,arm64,i328 and amrhf, which will take a bit longer but probably worth doing right in the long run.

@QuantumEntangledAndy
Copy link
Collaborator

So I have a working multiarch build

docker pull quantumentangledandy/neolink:rpi-docker

It works on my own raspberry pi but if anyone else can test that would be great.

It should support amd64, arm64, i328 and armhf

@joopy
Copy link

joopy commented Oct 1, 2020

I tried but failed. Installed docker and pulled quantumentangledandy/neolink:rpi-docker

root@dsmr:/home# docker run -p 8554:8554 --restart=on-failure --volume=$PWD/config.toml:/etc/neolink.toml quantumentangledandy/neolink
standard_init_linux.go:211: exec user process caused "exec format error"

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Oct 1, 2020

@joopy hmm odd it is certainly working on my raspberry pi.

Could you give me some details of your os and docker version. Perhaps it's an old docker from before multiarch was added.

Maybe you could also show me the log of

docker inspect quantumentangledandy/neolink:rpi-docker

@joopy
Copy link

joopy commented Oct 4, 2020

pi@dsmr:~ $ lscpu | grep Arch
Architecture: armv7l
pi@dsmr:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
pi@dsmr:~ $ docker inspect quantumentangledandy/neolink:rpi-docker
[
{
"Id": "sha256:0b27d85556fef857fb4e0551643a6deae8917048ea979a445fd338163e6e8e3c",
"RepoTags": [
"quantumentangledandy/neolink:rpi-docker"
],
"RepoDigests": [
"quantumentangledandy/neolink@sha256:ea60f26c751fabc13b01a52ef26ebd105ab5dc6280634510d9ac62374a1ce6ef"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2020-09-25T09:59:29.380535988Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": null,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"DockerVersion": "",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8554/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/usr/local/bin/neolink",
"--config",
"/etc/neolink.toml"
],
"ArgsEscaped": true,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"description": "An image for the neolink program which is a reolink camera to rtsp translator",
"maintainer": "QuantumEntangledAndy",
"repository": "QuantumEntangledAndy/neolink",
"version": "0.3.0"
}
},
"Architecture": "arm",
"Os": "linux",
"Size": 272856885,
"VirtualSize": 272856885,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/aa924d714e74a576cf723965aabef00825385819f6d39ba8bea751c8c480c236/diff:/var/lib/docker/overlay2/b0455e4c61a4cd44f926b46e8a6d6106640a52d765b295b0c31611139c4fecf4/diff:/var/lib/docker/overlay2/04a1b80c504640fddc75cf6ead2f3d659083553cf2711b3d007eb714da6ff148/diff",
"MergedDir": "/var/lib/docker/overlay2/07a13b8b2bf8f32a6cbd962d1306dccd4feae042e555e58a8c7ae016a12bed27/merged",
"UpperDir": "/var/lib/docker/overlay2/07a13b8b2bf8f32a6cbd962d1306dccd4feae042e555e58a8c7ae016a12bed27/diff",
"WorkDir": "/var/lib/docker/overlay2/07a13b8b2bf8f32a6cbd962d1306dccd4feae042e555e58a8c7ae016a12bed27/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:7f7c54bbd1d969debe25d3d7d96c798954afb853560f387ca11fbbdd2ff981be",
"sha256:885efa2f5644393858aa8649d0ccbc7534c077efba463ba671a6217b49dfdf1f",
"sha256:cb3bc03598fc90fc0f17dc3a88f89ebe6fe37cab3ba94a38a651104b3217e924",
"sha256:3f61cf3c7d56038270540d0c9dfc05f06d1cb6728c964c1b29f55b0b69778896"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]

pi@dsmr:~ $ docker run --rm -p 8559:8554 --volume=/opt/neolinks/config.toml:/home/pi/neolink.toml quantumentangledandy/neolink:rpi-docker
[2020-10-04T17:43:33Z INFO neolink] Neolink 0.3.0 (unknown commit) release
Error: IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })

/opt/neolinks/config.toml is an emtpy folder?

@QuantumEntangledAndy
Copy link
Collaborator

Your current error suggests that it is working but that you do not have the correct path to the config.

/opt/neolinks/config.toml should be the location of your neolink config file. I keep mine in /opt/neolinks but you should set it to where yours are located.

@joopy
Copy link

joopy commented Oct 5, 2020

thanks! I can confirm it is working. Mayby a small howto would be nice :)

@QuantumEntangledAndy
Copy link
Collaborator

The options --volume -p --restart-on are all part of docker run not our own code and is subject to change as docker changes. You can read them all here. On top of that some people would not use the command line to start it but some GUI or web-app that will be completely different for different people.

We do have a section called Docker in the readme. If you were to improve it what would your write?

@joopy
Copy link

joopy commented Oct 5, 2020

Must neolink with docker image work on all type off raspberry pi's? I just tried on a Raspberry pi 1 that isn't working..
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
pi@raspberrypi:~ $ lscpu | grep Arch
Architecture: armv6l

@QuantumEntangledAndy
Copy link
Collaborator

Not on armv6. I do not believe rust standard libraries supports armv6.

@QuantumEntangledAndy
Copy link
Collaborator

P.s. how long have you had that v1 for and how did you get Debian buster on it?

@QuantumEntangledAndy
Copy link
Collaborator

So I will see if I can get armel (v6) to work no guarentees but this suggests it might work if I can find a good enough cross compiler

@QuantumEntangledAndy
Copy link
Collaborator

@joopy I have an armv6 image, not sure if it works or not but please try, you need to re pull my image

docker pull quantumentangledandy/neolink:rpi-docker

@joopy
Copy link

joopy commented Oct 6, 2020

No output..

pi@raspberrypi:~ $ docker pull quantumentangledandy/neolink:rpi-docker
rpi-docker: Pulling from quantumentangledandy/neolink
a7c65856610c: Already exists
bfc6fc823b9c: Pull complete
e37a1078a0d0: Pull complete
a9be38b5db0f: Pull complete
Digest: sha256:b081b7eb07fe9de6c30fac784eef53baa4df229bf9f37948c775aa452a726253
Status: Downloaded newer image for quantumentangledandy/neolink:rpi-docker
docker.io/quantumentangledandy/neolink:rpi-docker
pi@raspberrypi:~ $ docker run --rm -p 8559:8554 --volume=/home/pi/neolink.toml:/etc/neolink.toml quantumentangledandy/neolink:rpi-docker
pi@raspberrypi:~ $

@QuantumEntangledAndy
Copy link
Collaborator

Nothing at all not even an error message is odd... I expect it to at least say file not found....

Could you set it to a higher logging level

docker run -e RUST_LOG=trace --rm -p 8559:8554 --volume=/home/pi/neolink.toml:/etc/neolink.toml quantumentangledandy/neolink:rpi-docker

@QuantumEntangledAndy
Copy link
Collaborator

If that dosen't work enter bash in the container

docker run --rm -it --entrypoint /bin/bash quantumentangledandy/neolink:rpi-docker

Check that the neolink binary is at /usr/local/bin/neolink inside the container

Then inside the containers bash run

/usr/local/bin/neolink --help

To see if it is running

@joopy
Copy link

joopy commented Oct 12, 2020

No succes..

pi@raspberrypi:~ $ nano /home/pi/neolink.toml
pi@raspberrypi:~ $ docker run -e RUST_LOG=trace --rm -p 8559:8554 --volume=/home/pi/neolink.toml:/etc/neolink.toml quantumentangledandy/neolink:rpi-docker
pi@raspberrypi:~ $ docker run --rm -it --entrypoint /bin/bash quantumentangledandy/neolink:rpi-docker
pi@raspberrypi:~ $ /usr/local/bin/neolink --help
-bash: /usr/local/bin/neolink: No such file or directory
pi@raspberrypi:~ $

@QuantumEntangledAndy
Copy link
Collaborator

That's a shame, we are changing how we deploy and install the multi arch docker so it may work after that. But it will take about a week before I can get it and everything else done. I'll ping you when it's ready for a retest if your willing.

@JoaoNogueira-xyz JoaoNogueira-xyz linked a pull request Oct 16, 2020 that will close this issue
@thirtythreeforty thirtythreeforty added the ci Continuous integration/build label Dec 10, 2020
@thirtythreeforty
Copy link
Owner

So #76 and #84 make a good first pass at this, thanks for working out the kinks (particularly Alpine's ARM stuff). However, I've just noticed that the docker/build-push-action now supports buildx directly. It looks like a really clean way to do multiarch Docker builds. I think I'd like to try to merge the two existing PRs' approaches with v2 of the action.

@QuantumEntangledAndy
Copy link
Collaborator

both pull requests #76 and #84 are using version 2 and the built in dockerx.

@thirtythreeforty
Copy link
Owner

thirtythreeforty commented Dec 11, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Continuous integration/build enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants