tagyoureit / nodejs-poolController

An application to control pool equipment from various manufacturers.
GNU Affero General Public License v3.0
313 stars 91 forks source link

[BUG] Docker images post 7.6.1 fail to start for me #854

Closed nicksardo closed 3 weeks ago

nicksardo commented 9 months ago

nodejs-poolController Version/commit

8.0.3

nodejs-poolController-dashPanel Version/commit

No response

relayEquipmentManager Version/commit

No response

Node Version

No response

Platform

No response

RS485 Adapter

No response

Are you using Docker?

OCP

No response

Pump(s)

No response

Chlorinator(s)

No response

What steps will reproduce the bug?

My docker-compose file:

  pool-controller:
    container_name: pool-controller
    image: "msmi/nodejs-poolcontroller:8.0.3"
    restart: always
    group_add:
      - dialout
    devices:
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AB0OHEL7-if00-port0:/dev/ttyUSB0
    ports:
      - "4200:4200"
    environment:
      - TZ=America/Los_Angeles
    volumes:
      - poolctrl:/app
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro

What happens?

Image 7.6.1 works perfectly fine, but using anything fails immediately with the following:

Error: Error relocating /app/node_modules/@serialport/bindings/build/Release/bindings.node: _ZN2v82V818GlobalizeReferenceEPNS_8internal7IsolateEPm: symbol not found
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at bindings (/app/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/app/node_modules/@serialport/bindings/lib/linux.js:2:36)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/app/node_modules/@serialport/bindings/lib/index.js:14:22)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)

What should have happened?

Logs show the following with 7.6.1:

Init state for Pool Controller
Pentair EasyTouch System Detected!
RS485 Stats:{ "bytesReceived": 1219 "success": 48, "failed": 1, "bytesSent": 456, "collisions": 0, "failureRate": 2.04% }

Additional information

No response

tagyoureit commented 9 months ago

njsPC v8 and the SerialPort module require node v16 or greater (16 or 18 recommended). You will need to rebuild the dependencies (npm i).

Others have v8.0.x running - https://github.com/tagyoureit/nodejs-poolController/issues/786.

nicksardo commented 9 months ago

Why isn't the docker image shipped with the correct node version? Nobody should have to go into a container to update dependencies.

tagyoureit commented 9 months ago

@emes Owns the docker image and build.

emes commented 8 months ago

Hey. Sorry for the delay @nicksardo

As I've said before. I'd be super happy not to own this. It really should be done via GitHub Actions or similar by the maintainers or if someone else wants to volunteer.

Yes, something definitely changed in the source after 7.6.1. I looked through the commits and I cannot determine what change hurt docker. If I recall, I had to make some changes to my dockerfile to get around it.

Having said that, it is working for me. I am running on x86_64.

/app $ node -v v18.18.1

Here's the Dockerfile I am using:

FROM node:lts-alpine AS build
RUN apk add --no-cache make gcc g++ python3 linux-headers udev tzdata
WORKDIR /app
COPY package*.json ./
COPY defaultConfig.json config.json
RUN npm ci
COPY . .
RUN npm run build
RUN npm ci --omit=dev

FROM node:lts-alpine as prod
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
ENV SOURCE_BRANCH=$SOURCE_BRANCH
ENV SOURCE_COMMIT=$SOURCE_COMMIT
RUN mkdir /app && chown node:node /app
WORKDIR /app
COPY --chown=node:node --from=build /app .
USER node
ENV NODE_ENV=production
ENTRYPOINT ["node", "dist/app.js"]

this runs using docker buildx over a buildx cluster so I can build natively for multiple architectures.

So I'm not sure how you'd be getting a node version other than v18.18.1 from the current image as npm ci installs whatever package.json asks.

Also probably best to pull latest rather than 8.0.3 as updates come after each tagged version and occasionally package.json version gets updated and git tags don't get pushed at the same time.

emes commented 8 months ago

if after pulling msmi/nodejs-poolcontroller (without the version tag) and if it's not working let me know.

also, you can try with socat...

  pool-controller:
    ...
    environment:
      - POOL_NET_CONNECT=true
      - POOL_NET_HOST=socat

  socat:
    command: tcp-listen:9801,fork,reuseaddr file:/dev/ttyUSB0,b9600,raw,echo=0
    container_name: socat
    restart: always
    ports:
      - "9801:9801"
    devices:
      - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AB0OHEL7-if00-port0:/dev/ttyUSB0
    image: alpine/socat
nicksardo commented 8 months ago

I tried building a new image with the latest node, didn't help. I also tried using switching the base image to debian instead of alpine. I just ran into other problems that I ran out of interest in solving.

Thanks for posting that socat bypass, but the pool controller container still fails with the same log message. I'm just going to stick with 7.6.1. Dependency jankiness like this is why I've spent the last ten years coding in Go.

emes commented 8 months ago

Yup. I get it. But just so I know, did you pull/use msmi/nodejs-poolcontroller:latest for those last tests?

nicksardo commented 8 months ago

Yep, I pulled the latest that you pushed. Thanks for trying.

Botched1 commented 8 months ago

Not that this helps at all, but I'm in the same boat.

No docker image version past the 7.6.1 one will run/stay running for me either.

emes commented 8 months ago

Can you post whatever error you're seeing and uname -a

Botched1 commented 8 months ago

It doesn't stay running long enough to shell in and get a uname -a.... Unless I'm missing a clever way of doing it that I'm not thinking of?

Docker log for the container:

Init state for Pool Controller
[10/27/2023, 2:41:12 PM] info: The current git branch output is master
[10/27/2023, 2:41:12 PM] info: The current git commit output is 0bc57fc
[10/27/2023, 2:41:12 PM] info: Starting up SSDP server
[10/27/2023, 2:41:12 PM] info: Init mqtt interface: MQTT
[10/27/2023, 2:41:12 PM] info: Initializing MQTT client MQTT
Init state for Pool Controller
[10/27/2023, 2:41:17 PM] info: The current git branch output is master
[10/27/2023, 2:41:17 PM] info: The current git commit output is 0bc57fc
[10/27/2023, 2:41:17 PM] info: Starting up SSDP server
[10/27/2023, 2:41:17 PM] info: Init mqtt interface: MQTT
[10/27/2023, 2:41:17 PM] info: Initializing MQTT client MQTT
Init state for Pool Controller
[10/27/2023, 2:41:22 PM] info: The current git branch output is master
[10/27/2023, 2:41:22 PM] info: The current git commit output is 0bc57fc
[10/27/2023, 2:41:22 PM] info: Starting up SSDP server
[10/27/2023, 2:41:22 PM] info: Init mqtt interface: MQTT
[10/27/2023, 2:41:22 PM] info: Initializing MQTT client MQTT

My compose file (running on an rpi4 - Linux pool 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux):

services:
  poolcontroller:
    container_name: poolcontroller
    restart: always
    environment:
      - TZ=America/Chicago
    group_add:
      - dialout
    devices:
      - /dev/ttyUSB0
    ports:
      - "4200:4200"
    volumes:
      - /home/jason/poolcontroller/config.json:/app/config.json
      - /home/jason/poolcontroller/data:/app/data
#    image: msmi/nodejs-poolcontroller:7.6.1
    image: msmi/nodejs-poolcontroller:latest
  poolcontroller-dashpanel:
    restart: always
    container_name: poolcontroller-dashpanel
    environment:
      - TZ=America/Chicago
    ports:
      - "5150:5150"
    volumes:
      - /home/jason/poolcontroller-dashpanel/config.json:/app/config.json
    image: msmi/nodejs-poolcontroller-dashpanel
    depends_on:
      - poolcontroller
gavc1 commented 7 months ago

+1 I migrated my install to docker, with a brand new install and ran in to this issue starting, it gets in a restart loop, same logs as Botched1 Node.js v18.15.0

emes commented 6 months ago

Please pull the latest and let me know how it goes:

docker pull msmi/nodejs-poolcontroller

Botched1 commented 6 months ago

Please pull the latest and let me know how it goes:

docker pull msmi/nodejs-poolcontroller

Sorry for the delay. I repulled latest today, and it seems to work fine. Unlike my other attempts on v8 this version came right up and stayed running.

Not sure what you changed, but THANKS!

emes commented 6 months ago

That’s great to hear. I’ve switched from alpine to Debian slim base image. Alpine is smaller but there have been constant dependency issues so let’s see how Debian does.

nicksardo commented 6 months ago

@emes Using the latest image, I'm getting the following.

Error: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at bindings (/app/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/app/node_modules/@serialport/bindings/lib/linux.js:2:36)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/app/node_modules/@serialport/bindings/lib/index.js:14:22)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
emes commented 6 months ago

Thanks @nicksardo I will continue to investigate. Obviously pointing to serialport. If you have time/interest, I'd be curious if using socat (not as a fix but to test if there are other issues) works. Anyway config template is above if you want to give it a try.

emes commented 6 months ago

Would you tell me/remind me what you're running this on? Output of hostnamectl or uname -a would be great.

Also output of docker image ls msmi/nodejs-poolcontroller

nicksardo commented 6 months ago

I'll try using socat again.

 $ hostnamectl
 Static hostname: -------
       Icon name: computer-desktop
         Chassis: desktop
      Machine ID: -------
         Boot ID: -------
Operating System: Ubuntu 22.04.3 LTS                
          Kernel: Linux 5.19.11-051911-generic
    Architecture: x86-64
 Hardware Vendor: Micro-Star International Co., Ltd.
  Hardware Model: MS-7D25
$ docker image ls msmi/nodejs-poolcontroller
REPOSITORY                   TAG       IMAGE ID       CREATED         SIZE
msmi/nodejs-poolcontroller   latest    16ded5d0076b   2 days ago      404MB
msmi/nodejs-poolcontroller   7.6.1     43995527478e   22 months ago   190MB
nicksardo commented 6 months ago

@emes I tried using socat again, but the controller fails with the same No such file or directory error as I posted above. There are zero log messages besides that error, so it fails pretty fast.

tagyoureit commented 3 weeks ago

closing due to lack of activity.