openHAB Cloud setup

Hi,

I am testing setting up my self-hosted openHAB-Cloud in Docker with docker-compose.

I faced some issues with the docker-compose.yml at https://github.com/openhab/openhab-cloud/tree/master/deployment/docker

Mainly related to MongoDB

oh-mongodb |  14:39:33.76
oh-mongodb |  14:39:33.76 Welcome to the Bitnami mongodb container
oh-mongodb |  14:39:33.76 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mongodb
oh-mongodb |  14:39:33.76 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mongodb/issues
oh-mongodb |  14:39:33.76 Send us your feedback at containers@bitnami.com
oh-mongodb |  14:39:33.76
oh-mongodb |
oh-mongodb | 2019-10-11T14:39:33.781+0000 I STORAGE  [main] Max cache overflow file size custom option: 0
oh-mongodb | 2019-10-11T14:39:33.784+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=26daf74b3748
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] db version v4.0.12
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] git version: 5776e3cbf9e7afe86e6b29e22520ffb6766e95d4
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] allocator: tcmalloc
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] modules: none
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] build environment:
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten]     distmod: debian92
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten]     distarch: x86_64
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten]     target_arch: x86_64
oh-mongodb | 2019-10-11T14:39:33.786+0000 I CONTROL  [initandlisten] options: { net: { bindIpAll: true }, storage: { mmapv1: { smallFiles: true } } }
oh-mongodb | 2019-10-11T14:39:33.787+0000 I STORAGE  [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
oh-mongodb | 2019-10-11T14:39:33.787+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
oh-mongodb | 2019-10-11T14:39:33.787+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
oh-mongodb | 2019-10-11T14:39:33.787+0000 I CONTROL  [initandlisten] now exiting
oh-mongodb | 2019-10-11T14:39:33.787+0000 I CONTROL  [initandlisten] shutting down with code:100

I switched to the offical MongDB instead of bitnami and the following docker-compose.yml

version: '3'
services:
  app-1:
    container_name: oh-app-1
    image: docker.io/openhab/openhabcloud-app
    working_dir: /opt/openhabcloud
    networks:
      - proxy-tier
    links:
      - mongodb
      - redis
    ports:
      - "3000"
    depends_on:
      - mongodb
      - redis
    restart: always

  mongodb:
    container_name: oh-mongodb
    image: mongo:latest
    ports:
      - "27017:27017"
    networks:
      - proxy-tier
    volumes:
      - ./data/db:/data/db
      - ./data/db:/data/configdb
    restart: always

  redis:
    container_name: oh-redis
    image: bitnami/redis:latest
    networks:
      - proxy-tier
    ports:
      - "6379"
    environment:
      - REDIS_PASSWORD=123_openHAB
    restart: always

  nginx:
    container_name: oh-nginx
    image: docker.io/openhab/openhabcloud-nginx
    volumes:
      - app-1:/opt/openhabcloud
    networks:
      - proxy-tier
    ports:
      - "8060:8081"
      - "8443:8443"
    links:
      - app-1:app-1

volumes:
  app-1:

networks:
  proxy-tier:
    external:
      name: nginx-proxy

As you see, I have another network and different port mappings. The reason is that I have another nginx with TLS fronting Internet (not used yet).

When accessing http://host:8060 I see the login screen but all images, CSS, JS etc are not available (404)

Any idea why

Does the container have write access to ‘/data/db’ ? That is the exception being reporting while spinning up the mongo container.

Sorry I was a bit unclear.
With the original bitnami/mongodb images I got those errors.
I should have permissions as docker-compose creates the directories.

When I switched to the official mogodb (as in the docker-compose.yml) it seems to work fine. but when entering the frontend I get

Cannot load JS, CSS, images etc

Note: I have changed the exposed ports of nginx to 8060 and 8443

check the path in nginx settings:(in my case i have changed the path to …/openhab-cloud/…)

location /css {
    alias  /home/ubuntu/openhabcloud/public/css;
    }
location /js {
    alias /home/ubuntu/openhabcloud/public/js;
    }
location /img {
    alias /home/ubuntu/openhabcloud/public/img;
    }
location /bootstrap {
    alias /home/ubuntu/openhabcloud/public/bootstrap;
    }
location /font-icons {
    alias /home/ubuntu/openhabcloud/public/font-icons;
    }
location /fonts {
    alias /home/ubuntu/openhabcloud/public/fonts;
    }
location /js-plugin {
    alias /home/ubuntu/openhabcloud/public/js-plugin;
    }
location /staff/js-plugin {
    alias /home/ubuntu/openhabcloud/public/js-plugin;
    }
location /downloads {
    alias /home/ubuntu/openhabcloud/public/downloads;
    }

Thanks @Siam but when checking the app-1 container it uses the original configured dir:

/opt/openhabcloud/public $ ls -la
total 56
drwxr-xr-x   11 root     root          4096 Feb 11  2018 .
drwxr-xr-x    1 root     root          4096 Mar 22  2018 ..
-rw-r--r--    1 root     root          8196 Mar  4  2018 .DS_Store
drwxr-xr-x    5 root     root          4096 Dec 20  2016 bootstrap
drwxr-xr-x    2 root     root          4096 Aug  4  2017 css
drwxr-xr-x    2 root     root          4096 Dec 20  2016 downloads
drwxr-xr-x    3 root     root          4096 Dec 20  2016 font-icons
drwxr-xr-x    2 root     root          4096 Dec 20  2016 fonts
drwxr-xr-x    9 root     root          4096 Feb 19  2018 img
drwxr-xr-x    2 root     root          4096 May 28  2017 js
drwxr-xr-x   16 root     root          4096 Dec 20  2016 js-plugin
drwxr-xr-x    2 root     root          4096 Dec 20  2016 stylesheets

I however tested your but no difference.

I taking a step back and look what I have done.

I have used the directory at https://github.com/openhab/openhab-cloud/tree/master/deployment/docker incl the subdirs and files

No changes except to the docker-compose.yml with the following changes

  • bitnami-mongodb didn’t want to start so uses official Mongo.(and removed the argument --smallfiles)
  • Changed network since I have a proxy network already
  • Changed ports from 80 and 443 to 8060 and 8443 since they are already used

The docker-compose.yml used:

version: '3'
services:
  app-1:
    container_name: oh-app-1
    image: docker.io/openhab/openhabcloud-app
    working_dir: /opt/openhabcloud
    networks:
      - proxy-tier
    links:
      - mongodb
      - redis
    ports:
      - "3000"
    depends_on:
      - mongodb
      - redis
    restart: always

  mongodb:
    container_name: oh-mongodb
    image: mongo:latest
    command: mongod --bind_ip_all
    ports:
      - "27017:27017"
    networks:
      - proxy-tier
    volumes:
      - /data/db
      - /data/configdb
    restart: always

  redis:
    container_name: oh-redis
    image: bitnami/redis:latest
    networks:
      - proxy-tier
    ports:
      - "6379"
    environment:
      - REDIS_PASSWORD=123_openHAB
    restart: always

  nginx:
    container_name: oh-nginx
    image: docker.io/openhab/openhabcloud-nginx
    volumes:
      - app-1:/opt/openhabcloud
    networks:
      - proxy-tier
    ports:
      - "8060:8081"
      - "8443:8443"
    links:
      - app-1:app-1

volumes:
  app-1:

networks:
  proxy-tier:
    external:
      name: nginx-proxy

In the Docker section of https://github.com/openhab/openhab-cloud/blob/master/README.md
it refers to Configuration and modifying the config.json

  • Where is that file located? It is not mounted as I can see but finds it in app-1 container.

I see:

oh-app-1   | 2019-10-13T10:50:53.789Z - info: Redis is ready
oh-app-1   | 2019-10-13T10:50:53.807Z - info: openHAB-cloud: Successfully connected to mongodb

I think there are missing pieces in the description on how to run openhab-cloud in Docker