jira/deploy/install.sh
vickytechkey 4eeaebf205
Some checks failed
Deploy Plane Project Tracker / Deploy to cisystem (push) Failing after 9s
ci: build and deploy custom images via tarball transfer
2026-09-19 21:26:59 +05:30

92 lines
3.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
# ==============================================================================
# Plane Installation & Deployment Script for cisystem
# Target Directory: /home/ubuntu/plane
# Port: 127.0.0.1:8090 (Routed by Nginx to jira.tradhox.com)
# ==============================================================================
INSTALL_DIR="/home/ubuntu/plane"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "==> [1/6] Initializing Plane directory structure at ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}/patches" "${INSTALL_DIR}/logs"
# Verify .env exists
if [ ! -f "${INSTALL_DIR}/.env" ]; then
if [ -f "${SCRIPT_DIR}/.env.example" ]; then
echo "Notice: Creating initial .env from .env.example..."
cp "${SCRIPT_DIR}/.env.example" "${INSTALL_DIR}/.env"
else
echo "ERROR: ${INSTALL_DIR}/.env does not exist! Please ensure .env is populated."
exit 1
fi
else
echo "Existing ${INSTALL_DIR}/.env preserved safely."
fi
echo "==> [2/6] Syncing docker-compose and runtime patches..."
if [ "${SCRIPT_DIR}" != "${INSTALL_DIR}" ]; then
cp "${SCRIPT_DIR}/docker-compose.yml" "${INSTALL_DIR}/docker-compose.yml"
if [ -d "${SCRIPT_DIR}/patches" ]; then
cp -r "${SCRIPT_DIR}/patches/"* "${INSTALL_DIR}/patches/"
fi
else
echo "Already inside target directory ${INSTALL_DIR}."
fi
cd "${INSTALL_DIR}"
echo "==> [3/6] Loading or Pulling Docker images..."
if [ -f "custom-images.tar.gz" ]; then
echo "==> Loading custom images from tarball..."
docker load < custom-images.tar.gz
rm custom-images.tar.gz
export APP_RELEASE="preview"
echo "==> Pulling remaining images (preview)..."
docker compose pull space admin live plane-redis plane-mq proxy
else
echo "==> Pulling all Docker images..."
docker compose pull web space admin live api worker beat-worker migrator plane-redis plane-mq proxy
fi
echo "==> [4/6] Executing database migrations..."
docker compose run --rm migrator
echo "==> Generating frontend Enterprise patches..."
if [ -f "${INSTALL_DIR}/patches/patch_frontend.py" ]; then
python3 "${INSTALL_DIR}/patches/patch_frontend.py" "${INSTALL_DIR}/patches"
fi
echo "==> [5/6] Starting Plane containers without touching other host services..."
docker compose up -d --remove-orphans
echo "==> [6/6] Verifying service health..."
HEALTHY=false
for i in $(seq 1 45); do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8090/ || true)
if [ "$STATUS" = "200" ] || [ "$STATUS" = "302" ]; then
echo "✓ Plane is healthy! HTTP Status: $STATUS (http://127.0.0.1:8090/)"
HEALTHY=true
break
fi
echo "Waiting for Plane to be ready (attempt $i/45, status: $STATUS)..."
sleep 2
done
if [ "$HEALTHY" != "true" ]; then
echo "ERROR: Plane did not respond with 200/302 within 90 seconds. Checking logs:"
docker compose logs --tail=50 proxy api web
exit 1
fi
echo "==> Verifying existing cisystem services are undisturbed..."
for s in "3000:Forgejo" "3001:Docmost" "8084:OnlyOffice Portal" "8083:OnlyOffice Engine"; do
PORT="${s%%:*}"
NAME="${s##*:}"
CODE=$(curl -s -o /dev/null -w "%{http_code}" "http://127.0.0.1:${PORT}/" || true)
echo " - ${NAME} (Port ${PORT}): HTTP ${CODE}"
done
echo "✓ Plane installation / deployment completed successfully!"