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

Zigbee2mqtt in Docker on Nano Server image #1479

Closed
desertspider opened this issue Apr 29, 2019 · 12 comments
Closed

Zigbee2mqtt in Docker on Nano Server image #1479

desertspider opened this issue Apr 29, 2019 · 12 comments

Comments

@desertspider
Copy link

desertspider commented Apr 29, 2019

Would it be possible to make zigbee2mqtt docker run inside a Windows container base image so the command "docker inspect --format '{{.Os}}' koenkk/zigbee2mqtt" would show "windows".

In other words, zigbee2mqtt based on windows nanoserver 1809

This because in the next docker release, it is possible to mount the zigbee stick inside docker on a Windows host.
https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/hardware-devices-in-containers

@desertspider desertspider changed the title Docker in Windows container base image Zigbee2mqtt in Docker nanoserver image Apr 29, 2019
@desertspider desertspider changed the title Zigbee2mqtt in Docker nanoserver image Zigbee2mqtt in Docker on nanoserver image Apr 29, 2019
@desertspider desertspider changed the title Zigbee2mqtt in Docker on nanoserver image Zigbee2mqtt in Docker on Nano Server image Apr 29, 2019
@Koenkk
Copy link
Owner

Koenkk commented Apr 29, 2019

That would indeed be nice, could you make a Dockerfile based on the nano image?

@desertspider
Copy link
Author

desertspider commented Apr 30, 2019 via email

@Koenkk
Copy link
Owner

Koenkk commented Apr 30, 2019

Yes, just make it as small as possible.

@desertspider
Copy link
Author

desertspider commented May 1, 2019

Just made a quick and dirty dockerfile for testing purposes. For now i did use the powershell version, can change that later.

The dockerfile;

FROM mcr.microsoft.com/powershell:nanoserver-1809
USER Administrator

ADD https://nodejs.org/dist/v10.15.3/node-v10.15.3-win-x64.zip C:\\build\\node-v10.15.3-win-x64.zip
RUN pwsh -Command Expand-Archive C:\build\node-v10.15.3-win-x64.zip C:\; Rename-Item C:\node-v10.15.3-win-x64 node

ADD https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip C:\\build\\MinGit-2.21.0-64-bit.zip
RUN pwsh -Command Expand-Archive C:\build\MinGit-2.21.0-64-bit.zip C:\git

ENV PATH="$WindowsPATH;C:\node;C:\git\cmd"

RUN git clone https://github.com/Koenkk/zigbee2mqtt.git /app
WORKDIR /app
COPY run.sh /app
RUN npm install
RUN rmdir /Q /S C:\git

ENTRYPOINT cd c:\\app && npm start

The run command;
docker run -v c:\dockerdata\zigbee2mqtt:c:\app\data --isolation=process --device="class/86E0D1E0-8089-11D0-9CE4-08003E301F73" testapp:v1

The log

zigbee2mqtt@1.3.1 start C:\app
> node index.js

  zigbee2mqtt:info 5/1/2019, 7:30:58 AM Logging to directory: 'C:\app\data\log\2019-05-01.07-30-58'
  zigbee2mqtt:info 5/1/2019, 7:30:59 AM Starting zigbee2mqtt version 1.3.1 (commit #unknown)
  zigbee2mqtt:info 5/1/2019, 7:30:59 AM Starting zigbee-shepherd
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF62F53F04A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+5114
 2: 00007FF62F51A0C6 node::MakeCallback+4518
 3: 00007FF62F51AA30 node_module_register+2032

(log is longer)

if i occupy the com port by zigbee2mqtt on the host, i get the regular error message;

zigbee2mqtt:info 5/1/2019, 7:08:26 AM Error while starting zigbee-shepherd, attempting to fix... (takes 60 seconds)
  zigbee2mqtt:info 5/1/2019, 7:09:26 AM Starting zigbee-shepherd
  zigbee2mqtt:error 5/1/2019, 7:09:26 AM Error while starting zigbee-shepherd!

How can i debug the memory error?

@Koenkk
Copy link
Owner

Koenkk commented May 2, 2019

Did you try wechaty/wechaty#1435 (comment) ?

@desertspider
Copy link
Author

desertspider commented May 2, 2019

Did you try Chatie/wechaty#1435 (comment) ?

Yup, but dont think the default nodejs 1500 mb memory limit is the problem.
Zigbee2mqtt hangs for 90 sec on request REQ --> SYS:osalNvRead before hitting the memory limit. In this time the memory on the host system increases by 1500 mb.

  zigbee2mqtt:info 5/2/2019, 1:50:46 AM Starting zigbee-shepherd
2019-05-02T08:50:46.431Z zigbee-shepherd:init zigbee-shepherd booting...
2019-05-02T08:50:46.451Z zigbee-shepherd:request REQ --> SYS:osalNvRead
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

@desertspider
Copy link
Author

Got it working by using mcr.microsoft.com/windows/servercore:1809
So nanoserver is missing something......

@desertspider
Copy link
Author

Should i create a issue at https://github.com/zigbeer/zigbee-shepherd/ since they load a something that is missing in nanoserver?

@Koenkk
Copy link
Owner

Koenkk commented May 3, 2019

What exactly is it loading? zigbee-shepherd isn't maintained anymore so I forked it: https://github.com/koenkk/zigbee-shepherd

@desertspider
Copy link
Author

What exactly is it loading? zigbee-shepherd isn't maintained anymore so I forked it: https://github.com/koenkk/zigbee-shepherd

Only thing i know for sure that the full server version aka servercore, zigbee-shepherd works just fine. With nanoserver it goes in some sort of memory loop. So shepherd is trying to use a library not available in nanoserver. Question is, what library.

@desertspider
Copy link
Author

desertspider commented May 20, 2019

Cannot get it to work on a nanoserver image. Servercore does work, but image is huge.
Closing this since a docker image of 4.67GB is to much i guess.

The dockerfile:

FROM mcr.microsoft.com/windows/servercore:1809

USER ContainerAdministrator

COPY node-v10.15.3-win-x64\* /node

COPY git\* /git

ENV PATH="$WindowsPATH;C:\node;C:\git\cmd"

RUN git clone https://github.com/Koenkk/zigbee2mqtt.git /app
WORKDIR /app
RUN npm install
RUN rmdir /Q /S C:\git

ENTRYPOINT cd c:\\app && npm start

No copying of the config file, so when mounting c:\app\data, please add a config file yourself.

@Koenkk
Copy link
Owner

Koenkk commented May 20, 2019

@desertspider thanks for your investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants