Setting up my development environment for HABApp

This article will demonstrate how I set up my development environment for HABApp. Being new to HABApp, I recognize that my approach may not be the best, and I would greatly appreciate any feedback.

Before proceeding further, I’d like to extend my thanks to @Spaceman_Spiff for his outstanding work. It’s astonishing how well everything functions. I have done a good portion of porting from my jsr223/python rules and I am totally excited about the new possibilities with HABApp as a rules platform.

Installation HABApp as a docker container together with utilities

I manage all my containers with Portainer CE. I can only encourage people to do this as well.
On my host machine, I have the folder /datavol to which I map all my containers’ data and config volumes.

I then have only to back up this folder.

This folder is also published as a samba share to be accessed fro my MAC where I have Visual Studio Code running.
Following are the docker-compose files:

Portainer (started with docker-compose)

version: '3.8'
services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    privileged: true
    ports:
    - "8000:8000"
    - "9000:9000"
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /datavol/portainer/data:/data

HABApp and Frontail


version: '3.8'
services:
  habapp:
    image: spacemanspiff2007/habapp:latest
    container_name: habapp
    restart: always
    network_mode: host
    volumes:
      - /datavol/habapp:/habapp/config 
      - /datavol/habapp/lib:/habapp/config/lib

    environment:
      - HABAPP_CONF=${HABAPP_CONF:?error}
      - TZ=Europe/Berlin
      - USER_ID=9001
      - GROUP_ID=9001

  hab-log:
    image: lukics/frontail:armv7
    container_name: hab-log
    user: "9001:9001"
    command: 
      - "/habapp/config/log/HABApp.log"  
    restart: unless-stopped
    ports:
      - 9001:9001
    volumes:
      - /datavol/habapp:/habapp/config 

  hab-events:
    image: lukics/frontail:armv7
    container_name: hab-events
    user: "9001:9001"
    command: 
      - "/habapp/config/log/events.log" 
    restart: unless-stopped
    ports:
      - 9002:9001
    volumes:
      - /datavol/habapp:/habapp/config 

  habapp-dev:
    image: spacemanspiff2007/habapp:latest
    container_name: habapp-dev
    restart: always
    network_mode: host
    volumes:
      - /datavol/habapp-dev:/habapp/config 
      - /datavol/habapp-dev/lib:/habapp/config/lib

    environment:
      - HABAPP_CONF=${HABAPP_CONF:?error}
      - TZ=Europe/Berlin
      - USER_ID=9001
      - GROUP_ID=9001

  hab-log-dev:
    image: lukics/frontail:armv7
    container_name: hab-log-dev
    user: "9001:9001"
    command: 
      - "/habapp/config/log/HABApp.log"  
    restart: unless-stopped
    ports:
      - 9003:9001
    volumes:
      - /datavol/habapp-dev:/habapp/config 

  hab-events-dev:
    image: lukics/frontail:armv7
    container_name: hab-events-dev
    user: "9001:9001"
    command: 
      - "/habapp/config/log/events.log" 
    restart: unless-stopped
    ports:
      - 9004:9001
    volumes:
      - /datavol/habapp-dev:/habapp/config 

At the base /datavol folder now there are folder more habapp and habapp-dev.
together with the habapp container, there are also two instances of frontal started and connected to HABApp.log and event.log. The same for the habapp instance for development.

Why two instanced of HABApp?
One should run production code, the other can be stopped and Visual Studio Code could be attached to this folder and debugging can happen during development.

the 4 instances of frontal I use to visualise the log and events. on ports 9001-9004 a web-based log view is exposed.

I connect Visual Studio Code to habapp-dev as a project directory. There I defined launch.json as following:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python-Modul",
            "type": "python",
            "request": "launch",
            "module": "HABApp",
            "args": ["--config", "/Volumes/mount-vevedock-pro/habapp-dev"],
            "justMyCode": false,
            "cwd": "/Volumes/mount-vevedock-pro/habapp-dev"
        }
    ]
}

I have created a Python virtual environment under habapp-dev/env, where I did pip install habapp.

the additional modules which I need for my code running, e.g. yaml, pushover, etc. I install by:

pip install --upgrade --target=/Volumes/mount-vevedock-pro/habapp-dev/lib pushover

When a module I developed or ported from jsr223 I just copy the lib from habapp-dev to habapp and copy also the code from one rules directory to the other

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.