Insights Installation Problem

I’m trying to install the Insights app using a custom setup script, but it’s not getting installed. During the cloning step, the script seems to skip cloning the Insights app entirely.

Has anyone faced this issue? Any idea what might be causing the app to be skipped?

#!/bin/bash

Exit on any error

set -e

Add current date and time

echo “Script started at: $(date ‘+%Y-%m-%d %H:%M:%S’)”

Step 1: Export APPS_JSON

echo “Exporting APPS_JSON…”
export APPS_JSON=‘[
{
“url”: “GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)”,
“branch”: “v15.53.0”
},
{
“url”: “https://github.com/xyz/xyz_app.git”,
“branch”: “main”
},
{
“url”: “GitHub - frappe/insights: Open Source Business Intelligence Tool”,
“branch”: “develop”
}
]’

Base64 encode the APPS_JSON

echo “Encoding APPS_JSON to Base64…”
export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 -w 0)

Step 2: Docker build command with --no-cache

echo “Building Docker image…”
docker build --no-cache
–build-arg FRAPPE_PATH=GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
–build-arg APPS_JSON_BASE64=$APPS_JSON_BASE64
–tag=customapp:1.0.0
–file=images/custom/Containerfile .

Step 3: Bring down the Docker Compose project

echo “Bringing down Docker Compose project…”
docker compose --project-name erpnext-one -f gitops/erpnext-one.yaml down

Step 4: Bring up the Docker Compose project

echo “Bringing up Docker Compose project…”
docker compose --project-name erpnext-one -f gitops/erpnext-one.yaml up --scale backend=3 -d

services=(“erpnext-one-backend-1” “erpnext-one-backend-2” “erpnext-one-backend-3” “erpnext-one-queue-long-1”)

Loop through each service and run the commands

for service in “${services[@]}”; do
echo “Running commands in $service…”
docker exec $service bash -c "
source env/bin/activate &&
pip install -r apps/xyz_app/requirement.txt &&
bench migrate
bench config http_timeout 6000
"
done
echo “Running commands in erpnext-one-frontend-1…”
docker exec erpnext-one-frontend-1 bash -c "
bench config http_timeout 6000
"
echo “Installation completed on all containers.”
MAX_TRIES=25
TRIES=0
SITE_URL=“https://xyz.com/login

Loop for checking the site status

while [ $TRIES -lt $MAX_TRIES ]; do
HTTP_RESPONSE=$(curl -s -o /dev/null -w “%{http_code}” “$SITE_URL”)

if [ “$HTTP_RESPONSE” -eq 200 ]; then
echo “Site is up. HTTP response: $HTTP_RESPONSE.”
exit 0
else
echo “Attempt $((TRIES + 1)): Site is down. HTTP response: $HTTP_RESPONSE.”
docker restart erpnext-one-frontend-1 erpnext-one-backend-1 erpnext-one-backend-2 erpnext-one-backend-3

if [ $TRIES -eq $((MAX_TRIES - 1)) ]; then
  echo "Max attempts reached. Restarting containers..."
  exit 1
fi

TRIES=$((TRIES + 1))
sleep 40

fi
done

echo “Setup completed successfully!”