Skip to main content

How to extend the execution environment of code blocks

By default, in HAP the execution environment for code blocks is Node.js (10.18) and Python (3.6). Starting from v5.1, HAP will support the extension of more execution environment.

Currently, in addition to providing the default mirror: nocoly/hap-command:node1018-python36
There is also a relatively newer mirror available: nocoly/hap-command:node2011-python312
Considering compatibility issues, it supports switching between multiple versions or completely switching to the new version.

For extending dependencies of code blocks, view how to extend the dependencies of code blocks for more details. Just adjust the corresponding paths: change python3.6 to python3.12, and node-10.18.0 to node-20.11.

    1. Download the mirror (Offline Package)
    docker pull nocoly/hap-command:node2011-python312
  1. Modify the configuration file by adding the following configuration

    commandv2:
    image: nocoly/hap-command:node2011-python312
    environment:
    <<: *app-environment
  2. Create a configuration file for extending code block services, such as: /data/hap/script/volume/workflow/application-www-ext.properties, with the following content:

    md.grpc.client.MDCommandService[0].address=static://commandv2:9098
    md.grpc.client.MDCommandService[0].nodeVersion=20.11
    md.grpc.client.MDCommandService[0].pythonVersion=3.12
  3. Mount the configuration file by adding the following configuration to the volumes of the app service:

    volumes:
    - ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflow/application-www-ext.properties
    - ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflowconsumer/application-www-ext.properties
    - ./volume/workflow/application-www-ext.properties:/usr/local/MDPrivateDeployment/workflowintegration/application-www-ext.properties
  4. Restart the service