MQTT configuration nodes are not recognized when packaged in a subflow module

Hack / Solution

the Only possible solution is to export all the subflows as a single JSON and pack these flows into /data/flows.json

This maintains the MQTT configuration and one is able to connect to MQTT Broker.

node-red/flows.json

add the flows.json to the node-red/ directory

[
{
        "id": "45db115760787ca3",
        "type": "subflow",
        "name": "internal mqtt in",
        "info": "# Internal MQTT In Node\n\nAutomatically connects to the Internal MQTT Broker and subscribes to User-Defined MQTT Topics\n\n## Subscribe to MQTT Topics\n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `subscribe`\n- `msg.topic` = `YOUR/TOPIC/HERE`\n\nand connect to this node\n\n## Disconnect from Internal MQTT Broker\n> NOTE: If you disconnect from the broker, you will need to reconnect again\n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `disconnect`\n\nand connect to this node\n\n## Reconnect to Internal MQTT Broker\n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `connect`\n\nand connect to this node\n\n## Unsubscribe from MQTT Topics\n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `unsubscribe`\n- `msg.topic` = (select boolean) `true`\n\nand connect to this node",
        "category": "custom-nodes",
        "in": [
            {
                "x": 220,
                "y": 100,
                "wires": [
                    {
                        "id": "cd6f53791302e5d9"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 560,
                "y": 100,
                "wires": [
                    {
                        "id": "cd6f53791302e5d9",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {
            "module": "subflow-mqtt-common",
            "type": "mqtt-internal-in",
            "version": "0.1.0",
            "author": "Shantanoo \"Shan\" Desai <sdes.softdev@gmail.com>",
            "desc": "MQTT In Node for Internal MQTT Broker",
            "keywords": "mqtt, subflows",
            "license": "Apache-2.0"
        },
        "color": "#F3B567",
        "icon": "node-red/bridge.svg",
        "status": {
            "x": 540,
            "y": 180,
            "wires": [
                {
                    "id": "cd6f53791302e5d9",
                    "port": 0
                }
            ]
        }
    },
    {
        "id": "cd6f53791302e5d9",
        "type": "mqtt in",
        "z": "45db115760787ca3",
        "name": "Internal MQTT Broker In",
        "topic": "",
        "qos": "2",
        "datatype": "auto",
        "broker": "1e34472ea3f09540",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 1,
        "x": 390,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "1e34472ea3f09540",
        "type": "mqtt-broker",
        "z": "45db115760787ca3",
        "name": "Internal MQTT Broker In Node",
        "broker": "internal-mqtt-broker",
        "port": "1883",
        "clientid": "red-client-mqtt-internal-in",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": "",
        "credentials": {
            "user": "",
            "password": ""
        }
    },
    {
        "id": "ced02ad71788907a",
        "type": "subflow",
        "name": "internal mqtt out",
        "info": "# Internal MQTT Out Node\n\nAutomatically connects to the Internal MQTT Broker and publish to User-Defined MQTT Topics\n\n## Subscribe to MQTT Topics\n\nCreate an __Inject__ node with following:\n\n- `msg.topic` = `YOUR/TOPIC/HERE`\n\nand connect to this node\n\n## Disconnect from INternal MQTT Broker\n\n> NOTE: If you disconnect from the broker, you will need to reconnect again. \n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `disconnect`\n\nand connect to this node\n\n## Reconnect to Internal MQTT Broker\n\nCreate an __Inject__ node with following:\n\n- `msg.action` = `connect`\n\nand connect to this node",
        "category": "custom-nodes",
        "in": [
            {
                "x": 160,
                "y": 180,
                "wires": [
                    {
                        "id": "f40d0dbc09407cae"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {
            "module": "subflow-mqtt-common",
            "type": "mqtt-internal-out",
            "version": "0.1.0",
            "author": "Shantanoo \"Shan\" Desai <sdes.softdev@gmail.com>",
            "desc": "MQTT Out Node for Internal Broker",
            "keywords": "mqtt, subflows",
            "license": "Apache-2.0"
        },
        "color": "#F3B567",
        "icon": "node-red/bridge.svg"
    },
    {
        "id": "4afe4316918f609c",
        "type": "mqtt-broker",
        "z": "ced02ad71788907a",
        "name": "Internal MQTT Broker Out Node",
        "broker": "internal-mqtt-broker",
        "port": "1883",
        "clientid": "red-client-mqtt-internal-out",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": "",
        "credentials": {
            "user": "",
            "password": ""
        }
    },
    {
        "id": "f40d0dbc09407cae",
        "type": "mqtt out",
        "z": "ced02ad71788907a",
        "name": "MQTT Internal Broker Out",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "4afe4316918f609c",
        "x": 390,
        "y": 180,
        "wires": []
    }
]

Dockerfile

FROM nodered/node-red:2.2.2

# Copy all node-red related files
COPY node-red/flows.json /data/flows.json
COPY package.json .

RUN npm install --unsafe-perm --no-update-notifier --no-audit --only=production