- Update all submodule URLs from gitea.centraal.wbd-rd.nl to gitea.wbd-rd.nl - Add settler as proper submodule in .gitmodules - Add agent skills, function anchors, decisions, and improvements - Add Docker configuration and scripts - Add manuals and third_party docs - Update .gitignore with secrets and build artifacts - Remove stale .tgz build artifact Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
85 lines
2.9 KiB
Bash
85 lines
2.9 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
EVOLV_DIR="/data/evolv"
|
|
USER_DIR="/data"
|
|
|
|
echo "=== EVOLV Node-RED Development Container ==="
|
|
echo "Starting at $(date)"
|
|
|
|
# -------------------------------------------------------
|
|
# 1. Verify node_modules exist (first start or volume wipe)
|
|
# -------------------------------------------------------
|
|
if [ ! -d "$EVOLV_DIR/node_modules" ]; then
|
|
echo "[entrypoint] node_modules missing — running npm install..."
|
|
cd "$EVOLV_DIR"
|
|
npm install --ignore-scripts
|
|
echo "[entrypoint] npm install complete."
|
|
fi
|
|
|
|
# -------------------------------------------------------
|
|
# 2. Repair generalFunctions symlink if broken by bind mount
|
|
# -------------------------------------------------------
|
|
GF_LINK="$EVOLV_DIR/node_modules/generalFunctions"
|
|
GF_TARGET="$EVOLV_DIR/nodes/generalFunctions"
|
|
|
|
if [ -L "$GF_LINK" ] && [ ! -e "$GF_LINK" ]; then
|
|
echo "[entrypoint] Repairing broken generalFunctions symlink..."
|
|
rm -f "$GF_LINK"
|
|
ln -s "$GF_TARGET" "$GF_LINK"
|
|
echo "[entrypoint] Symlink repaired."
|
|
elif [ ! -e "$GF_LINK" ]; then
|
|
echo "[entrypoint] Creating generalFunctions symlink..."
|
|
ln -s "$GF_TARGET" "$GF_LINK"
|
|
echo "[entrypoint] Symlink created."
|
|
fi
|
|
|
|
# -------------------------------------------------------
|
|
# 3. Install EVOLV into Node-RED user dir
|
|
# This ensures node-red.nodes mapping is discovered
|
|
# -------------------------------------------------------
|
|
if [ ! -f "$USER_DIR/package.json" ]; then
|
|
echo "[entrypoint] Initializing Node-RED user dir..."
|
|
cat > "$USER_DIR/package.json" << 'PKGJSON'
|
|
{
|
|
"name": "evolv-nodered-userdir",
|
|
"description": "Node-RED user directory for EVOLV dev",
|
|
"version": "1.0.0",
|
|
"private": true,
|
|
"dependencies": {}
|
|
}
|
|
PKGJSON
|
|
fi
|
|
|
|
# Link EVOLV package into the Node-RED user dir
|
|
cd "$USER_DIR"
|
|
npm install --no-save "$EVOLV_DIR" 2>/dev/null || {
|
|
echo "[entrypoint] npm install of EVOLV package failed, attempting symlink fallback..."
|
|
mkdir -p "$USER_DIR/node_modules"
|
|
rm -rf "$USER_DIR/node_modules/EVOLV"
|
|
ln -s "$EVOLV_DIR" "$USER_DIR/node_modules/EVOLV"
|
|
}
|
|
|
|
echo "[entrypoint] EVOLV nodes installed into Node-RED user dir."
|
|
|
|
# -------------------------------------------------------
|
|
# 4. Deploy demo flow if no user flow exists yet
|
|
# -------------------------------------------------------
|
|
DEMO_FLOW="$EVOLV_DIR/docker/demo-flow.json"
|
|
FLOW_FILE="/data/flows.json"
|
|
|
|
if [ -f "$DEMO_FLOW" ]; then
|
|
# Deploy demo flow if flows.json is missing or is the default stub
|
|
if [ ! -f "$FLOW_FILE" ] || grep -q "WARNING: please check" "$FLOW_FILE" 2>/dev/null; then
|
|
echo "[entrypoint] Deploying demo flow..."
|
|
cp "$DEMO_FLOW" "$FLOW_FILE"
|
|
echo "[entrypoint] Demo flow deployed to $FLOW_FILE"
|
|
fi
|
|
fi
|
|
|
|
# -------------------------------------------------------
|
|
# 5. Start Node-RED with custom settings
|
|
# -------------------------------------------------------
|
|
echo "[entrypoint] Starting Node-RED..."
|
|
exec node-red --settings "$EVOLV_DIR/docker/settings.js"
|