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

Gateway 1.1 docker image does not work for fresh installs #3043

Open
werto165 opened this issue Dec 14, 2022 · 10 comments
Open

Gateway 1.1 docker image does not work for fresh installs #3043

werto165 opened this issue Dec 14, 2022 · 10 comments
Labels
Milestone

Comments

@werto165
Copy link

I am trying to run the follow image: webthingsio/gateway:1.1.0-alpha.1 on bullseye

+ WEBTHINGS_HOME=/home/node/.webthings
+ args=
+ start_task=run-only
+ is_container
+ '[' -f /.dockerenv ']'
+ return 0
++ node --version
++ egrep -o '[0-9]+'
++ head -n1
+ _node_version=12
+ [[ ! -f /home/node/.webthings/.node_version ]]
+ cd /home/node/webthings/gateway
+ mkdir -p /home/node/.webthings/config
+ ./tools/update-addons.sh
Creating database: /home/node/.webthings/config/db.sqlite3
/home/node/webthings/gateway/build/models/things.js:377
addon_manager_1.default.on(Constants.THING_ADDED, (thing) => {
                        ^

TypeError: Cannot read property 'on' of undefined
    at Object.<anonymous> (/home/node/webthings/gateway/build/models/things.js:377:25)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/node/webthings/gateway/build/models/actions.js:40:34)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
Process 10 died: No such process; trying to remove PID file. (/run/avahi-daemon//pid)
+ WEBTHINGS_HOME=/home/node/.webthings
+ args=
+ start_task=run-only
+ is_container
+ '[' -f /.dockerenv ']'
+ return 0
++ node --version
++ egrep -o '[0-9]+'
++ head -n1
+ _node_version=12
+ [[ ! -f /home/node/.webthings/.node_version ]]
+ cd /home/node/webthings/gateway
+ mkdir -p /home/node/.webthings/config
+ ./tools/update-addons.sh
Opening database: /home/node/.webthings/config/db.sqlite3
/home/node/webthings/gateway/build/models/things.js:377
addon_manager_1.default.on(Constants.THING_ADDED, (thing) => {
                        ^

TypeError: Cannot read property 'on' of undefined
    at Object.<anonymous> (/home/node/webthings/gateway/build/models/things.js:377:25)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/node/webthings/gateway/build/models/actions.js:40:34)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

seems like addon_manager_1.default is not being created therefore its null. any help would be appreciated

@benfrancis benfrancis added the bug label Dec 15, 2022
@benfrancis benfrancis added this to the 1.1 milestone Dec 15, 2022
@benfrancis
Copy link
Member

@werto165 Thanks for the bug report.

Can you please test 1.1.0-beta.2 and let me know whether you're still seeing this issue? https://hub.docker.com/layers/webthingsio/gateway/1.1.0-beta.2/images/sha256-db33eda9461c15f08fce3118cdef3d2a08b6155721564293d97c9386e426deaf?context=explore

@MichaelKohler
Copy link

I'm running 1.1.0-beta.2 on bullseye (Raspbian, Pi 4 Model B) without any issue:

 ❯ docker ps -a
CONTAINER ID   IMAGE                              COMMAND                  CREATED         STATUS       PORTS                                                                                                                             NAMES
f8071075060f   webthingsio/gateway:1.1.0-beta.2   "/init.sh"               10 days ago     Up 10 days                                                                                                                                     webthings

@benfrancis benfrancis removed this from the 1.1 milestone Jan 3, 2023
@ianlockhead
Copy link

Hi, I have same issue with docker on Ubuntu. Was this fixed in stable release 1.1?

@benfrancis
Copy link
Member

benfrancis commented Jan 9, 2023

See also: https://discourse.mozilla.org/t/issue-starting-docker-image/109712/2 for someone else experiencing this issue.

@ianlockhead
Copy link

ianlockhead commented Jan 10, 2023

@benfrancis OK so after few attempts I find out where the problem was. An incorrect config in the portainer stack with timezone settings. Image with Gateway 1.1.0 is fully working now! The correct config for portainer stack or docker-compose is:

version: '4'
services:
  webthings:
    container_name: webthings
    image: "webthingsio/gateway"
    volumes:
      - /home/dell/docker/webthings/:/home/node/.webthings
    network_mode: host
    environment:
      - "TZ=Europe/Prague"
    restart: always
    logging:

      options:
        max-size: "1m"
        max-file: "10"

@benfrancis
Copy link
Member

See also: #3065, in which the same error is produced on a Raspberry Pi 3.

@benfrancis
Copy link
Member

benfrancis commented Jan 19, 2023

#3065 (comment) suggests that the 1.1 docker image only works when upgrading a 1.0 image and the 1.1 image doesn't work when installed from fresh. Possibly because the SQLite database doesn't get created properly on first start.

It would be good if someone could test that and report back if they can reproduce it.

Edit: It appears just copying an SQLite database from a 1.0 installation doesn't fix the problem, files generated by the 1.0 installation are needed #3065 (comment)

@benfrancis
Copy link
Member

#3066 (comment) offers a workaround "putting a text file in the /home/node/.webthings folder named .node_version and ensure it's content is 12 will result in the image starting properly"

@benfrancis benfrancis changed the title Raspberry pi 4 bullseye not running docker container. Gateway 1.1 docker image does not work for fresh installs Jan 23, 2023
@benfrancis
Copy link
Member

Thanks for the workaround, @kcusoundman.

It would be great if we could turn that into a patch so we can release a working 1.1.1 release of the docker image.

As far as I can tell, the .node_version file is meant to be created by run-app.sh if the gateway is running inside a container and the file does not already exist. See lines 48-62 https://github.com/WebThingsIO/gateway/blob/v1.1.X/run-app.sh#L48

At a guess one of the lines between line 56 and 59 is failing to execute and causing the startup script to crash. If the file already exists and its contents matches the node version running inside the container then those lines are skipped.

Is anyone able to debug this inside a docker container and come up with a proposed fix?

@benfrancis
Copy link
Member

See also #3109

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

No branches or pull requests

4 participants