From 4b7dd918c3dc4215311d21fbca252b4ee21bbf3c Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 14:54:02 +0530 Subject: [PATCH 01/15] removed code build process from install script --- deploy/selfhost/docker-compose.yml | 16 ++-- deploy/selfhost/install.sh | 132 +++++++---------------------- 2 files changed, 40 insertions(+), 108 deletions(-) diff --git a/deploy/selfhost/docker-compose.yml b/deploy/selfhost/docker-compose.yml index 5a7b1acfc66..4c540ec5c07 100644 --- a/deploy/selfhost/docker-compose.yml +++ b/deploy/selfhost/docker-compose.yml @@ -44,7 +44,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-frontend:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: node web/server.js web deploy: @@ -57,7 +57,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-space:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: node space/server.js space deploy: @@ -71,7 +71,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-admin:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: node admin/server.js admin deploy: @@ -84,7 +84,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: ./bin/docker-entrypoint-api.sh deploy: @@ -99,7 +99,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: ./bin/docker-entrypoint-worker.sh volumes: @@ -113,7 +113,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: unless-stopped command: ./bin/docker-entrypoint-beat.sh volumes: @@ -127,7 +127,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present restart: "no" command: ./bin/docker-entrypoint-migrator.sh volumes: @@ -167,7 +167,7 @@ services: <<: *app-env image: ${DOCKERHUB_USER:-makeplane}/plane-proxy:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} - pull_policy: ${PULL_POLICY:-always} + pull_policy: if_not_present ports: - ${NGINX_PORT}:80 depends_on: diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index fb248509aa3..7a637440ce0 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -1,13 +1,12 @@ #!/bin/bash -BRANCH=master +BRANCH=${BRANCH=master} SCRIPT_DIR=$PWD SERVICE_FOLDER=plane-app PLANE_INSTALL_DIR=$PWD/$SERVICE_FOLDER -export APP_RELEASE=$BRANCH +export APP_RELEASE="stable" export DOCKERHUB_USER=makeplane -export PULL_POLICY=always -USE_GLOBAL_IMAGES=1 +export PULL_POLICY=if_not_present RED='\033[0;31m' YELLOW='\033[1;33m' @@ -31,60 +30,6 @@ Project management tool from the future EOF } -function buildLocalImage() { - if [ "$1" == "--force-build" ]; then - DO_BUILD="1" - elif [ "$1" == "--skip-build" ]; then - DO_BUILD="2" - else - printf "\n" >&2 - printf "${YELLOW}You are on ${CPU_ARCH} cpu architecture. ${NC}\n" >&2 - printf "${YELLOW}Since the prebuilt ${CPU_ARCH} compatible docker images are not available for, we will be running the docker build on this system. ${NC} \n" >&2 - printf "${YELLOW}This might take ${YELLOW}5-30 min based on your system's hardware configuration. \n ${NC} \n" >&2 - printf "\n" >&2 - printf "${GREEN}Select an option to proceed: ${NC}\n" >&2 - printf " 1) Build Fresh Images \n" >&2 - printf " 2) Skip Building Images \n" >&2 - printf " 3) Exit \n" >&2 - printf "\n" >&2 - read -p "Select Option [1]: " DO_BUILD - until [[ -z "$DO_BUILD" || "$DO_BUILD" =~ ^[1-3]$ ]]; do - echo "$DO_BUILD: invalid selection." >&2 - read -p "Select Option [1]: " DO_BUILD - done - echo "" >&2 - fi - - if [ "$DO_BUILD" == "1" ] || [ "$DO_BUILD" == "" ]; - then - REPO=https://github.com/makeplane/plane.git - CURR_DIR=$PWD - PLANE_TEMP_CODE_DIR=$(mktemp -d) - git clone $REPO $PLANE_TEMP_CODE_DIR --branch $BRANCH --single-branch - - cp $PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml $PLANE_TEMP_CODE_DIR/build.yml - - cd $PLANE_TEMP_CODE_DIR - if [ "$BRANCH" == "master" ]; - then - export APP_RELEASE=stable - fi - - /bin/bash -c "$COMPOSE_CMD -f build.yml build --no-cache" >&2 - # cd $CURR_DIR - # rm -rf $PLANE_TEMP_CODE_DIR - echo "build_completed" - elif [ "$DO_BUILD" == "2" ]; - then - printf "${YELLOW}Build action skipped by you in lieu of using existing images. ${NC} \n" >&2 - echo "build_skipped" - elif [ "$DO_BUILD" == "3" ]; - then - echo "build_exited" - else - printf "INVALID OPTION SUPPLIED" >&2 - fi -} function install() { echo "Installing Plane.........." download @@ -107,39 +52,25 @@ function download() { mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH fi - if [ "$BRANCH" != "master" ]; - then - cp $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml - sed -e 's@${APP_RELEASE:-stable}@'"$BRANCH"'@g' \ - $PLANE_INSTALL_DIR/temp.yaml > $PLANE_INSTALL_DIR/docker-compose.yaml + # if [ "$BRANCH" != "master" ]; + # then + # cp $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml + # sed -e 's@${APP_RELEASE:-stable}@'"$BRANCH"'@g' \ + # $PLANE_INSTALL_DIR/temp.yaml > $PLANE_INSTALL_DIR/docker-compose.yaml - rm $PLANE_INSTALL_DIR/temp.yaml - fi + # rm $PLANE_INSTALL_DIR/temp.yaml + # fi - if [ $USE_GLOBAL_IMAGES == 0 ]; then - local res=$(buildLocalImage) - # echo $res - - if [ "$res" == "build_exited" ]; - then - echo - echo "Install action cancelled by you. Exiting now." - echo - exit 0 - fi - else - /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull" - fi + /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull --policy $PULL_POLICY" echo "" echo "Most recent Stable version is now available for you to use" echo "" echo "In case of Upgrade, your new setting file is availabe as 'variables-upgrade.env'. Please compare and set the required values in 'plane.env 'file." echo "" - } function startServices() { - /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH up -d --quiet-pull" + /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH up -d --pull if_not_present --quiet-pull" local migrator_container_id=$(docker container ls -aq -f "name=$SERVICE_FOLDER-migrator") if [ -n "$migrator_container_id" ]; then @@ -354,7 +285,7 @@ function askForAction() { if [ "$ACTION" == "1" ] || [ "$DEFAULT_ACTION" == "install" ] then install - askForAction + # askForAction elif [ "$ACTION" == "2" ] || [ "$DEFAULT_ACTION" == "start" ] then startServices @@ -370,7 +301,7 @@ function askForAction() { elif [ "$ACTION" == "5" ] || [ "$DEFAULT_ACTION" == "upgrade" ] then upgrade - askForAction + # askForAction elif [ "$ACTION" == "6" ] || [ "$DEFAULT_ACTION" == "logs" ] then viewLogs $@ @@ -398,27 +329,28 @@ fi CPU_ARCH=$(uname -m) if [[ $FORCE_CPU == "amd64" || $CPU_ARCH == "amd64" || $CPU_ARCH == "x86_64" || ( $BRANCH == "master" && ( $CPU_ARCH == "arm64" || $CPU_ARCH == "aarch64" ) ) ]]; then - USE_GLOBAL_IMAGES=1 DOCKERHUB_USER=makeplane - PULL_POLICY=always -else - USE_GLOBAL_IMAGES=0 - DOCKERHUB_USER=myplane - PULL_POLICY=never -fi -if [ "$BRANCH" == "master" ]; -then - export APP_RELEASE=stable -fi + if [ "$BRANCH" == "master" ]; + then + export APP_RELEASE=stable + export PULL_POLICY=${PULL_POLICY:-always} + mkdir -p $PLANE_INSTALL_DIR/archive + fi -# REMOVE SPECIAL CHARACTERS FROM BRANCH NAME -if [ "$BRANCH" != "master" ]; -then - SERVICE_FOLDER=plane-app-$(echo $BRANCH | sed -r 's@(\/|" "|\.)@-@g') - PLANE_INSTALL_DIR=$PWD/$SERVICE_FOLDER + # REMOVE SPECIAL CHARACTERS FROM BRANCH NAME + if [ "$BRANCH" != "master" ]; + then + if [ $CPU_ARCH != "amd64" && $CPU_ARCH != "x86_64" ]; + then + echo "Since the prebuilt $CPU_ARCH compatible docker images are not available for $BRANCH, you need to build images using build.sh script." + exit 1 + fi + fi +else + echo "$CPU_ARCH is not supported at the moment. Make use of build.sh to build the images locally." + exit 1 fi -mkdir -p $PLANE_INSTALL_DIR/archive DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/plane.env From 5d1b9340d741d781c279575be8a811e1f36ebbaf Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 15:34:59 +0530 Subject: [PATCH 02/15] fixes in install.sh --- deploy/selfhost/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 7a637440ce0..87361f2ae12 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -330,12 +330,12 @@ CPU_ARCH=$(uname -m) if [[ $FORCE_CPU == "amd64" || $CPU_ARCH == "amd64" || $CPU_ARCH == "x86_64" || ( $BRANCH == "master" && ( $CPU_ARCH == "arm64" || $CPU_ARCH == "aarch64" ) ) ]]; then DOCKERHUB_USER=makeplane + mkdir -p $PLANE_INSTALL_DIR/archive if [ "$BRANCH" == "master" ]; then export APP_RELEASE=stable export PULL_POLICY=${PULL_POLICY:-always} - mkdir -p $PLANE_INSTALL_DIR/archive fi # REMOVE SPECIAL CHARACTERS FROM BRANCH NAME From b4ccc64cc2c92c07df4493eb07e6a34b018658a7 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 15:52:12 +0530 Subject: [PATCH 03/15] fixed docker-compose.yaml --- deploy/selfhost/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/selfhost/docker-compose.yml b/deploy/selfhost/docker-compose.yml index 4c540ec5c07..638452fd761 100644 --- a/deploy/selfhost/docker-compose.yml +++ b/deploy/selfhost/docker-compose.yml @@ -168,6 +168,7 @@ services: image: ${DOCKERHUB_USER:-makeplane}/plane-proxy:${APP_RELEASE:-stable} platform: ${DOCKER_PLATFORM:-} pull_policy: if_not_present + restart: unless-stopped ports: - ${NGINX_PORT}:80 depends_on: From 1b38b66de00c7b86843bc4c2c5b0cd5fd2f3aac8 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Wed, 24 Jul 2024 12:16:44 +0530 Subject: [PATCH 04/15] wip --- deploy/selfhost/build.yml | 2 - deploy/selfhost/install.sh | 184 ++++++++++++++++++++++++------------- 2 files changed, 119 insertions(+), 67 deletions(-) diff --git a/deploy/selfhost/build.yml b/deploy/selfhost/build.yml index e81701f5d39..b65d297e9fd 100644 --- a/deploy/selfhost/build.yml +++ b/deploy/selfhost/build.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: web: image: ${DOCKERHUB_USER:-local}/plane-frontend:${APP_RELEASE:-latest} diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 87361f2ae12..ff8fd8235af 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -6,12 +6,17 @@ SERVICE_FOLDER=plane-app PLANE_INSTALL_DIR=$PWD/$SERVICE_FOLDER export APP_RELEASE="stable" export DOCKERHUB_USER=makeplane -export PULL_POLICY=if_not_present +export PULL_POLICY=${PULL_POLICY:-if_not_present} RED='\033[0;31m' YELLOW='\033[1;33m' GREEN='\033[0;32m' NC='\033[0m' # No Color +CPU_ARCH=$(uname -m) + +mkdir -p $PLANE_INSTALL_DIR/archive +DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml +DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/plane.env function print_header() { clear @@ -30,11 +35,100 @@ Project management tool from the future EOF } +function spinner() { + local pid=$1 + local delay=.5 + local spinstr='|/-\' + + while [ "$(ps a | awk '{print $1}' | grep -w $pid)" ]; do + local temp=${spinstr#?} + printf " [%c] " "$spinstr" >&2 + local spinstr=$temp${spinstr%"$temp"} + sleep $delay + printf "\b\b\b\b\b\b" >&2 + done + printf " \b\b\b\b" >&2 +} + +function initialize(){ + printf "Please wait while we check the availability of Docker images for the selected release ($APP_RELEASE) with ${CPU_ARCH^^} support." >&2 + + # local IMAGE_NAME=makeplane/plane-proxy + # local IMAGE_TAG=${APP_RELEASE} + # docker manifest inspect ${IMAGE_NAME}:${IMAGE_TAG} | grep -q "\"architecture\": \"${CPU_ARCH}\"" & + # local pid=$! + # spinner $pid + + # echo "" >&2 + + # wait $pid + + + # if [ $? -eq 0 ]; then + # echo "Plane supports ${CPU_ARCH}" >&2 + # echo "available" + # return 0 + # else + echo "" >&2 + echo "" >&2 + echo "${CPU_ARCH^^} images are not available for selected release ($APP_RELEASE). Please use the 'Build Your Own Image' option to build the images locally." >&2 + echo "" >&2 + echo "build" + return 1 + # fi +} + +function buildYourOwnImage(){ + echo "Building images locally..." + + # checkout the code to ~/tmp/plane folder and build the images + local PLANE_TEMP_CODE_DIR=~/tmp/plane + rm -rf $PLANE_TEMP_CODE_DIR + mkdir -p $PLANE_TEMP_CODE_DIR + REPO=https://github.com/makeplane/plane.git + git clone $REPO $PLANE_TEMP_CODE_DIR --branch $BRANCH --single-branch --depth 1 + + cp $PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml $PLANE_TEMP_CODE_DIR/build.yml + + cd $PLANE_TEMP_CODE_DIR + if [ "$BRANCH" == "master" ]; + then + export APP_RELEASE=stable + fi + + export DOCKERHUB_USER=myplane + + /bin/bash -c "$COMPOSE_CMD -f build.yml build --no-cache" >&2 + if [ $? -ne 0 ]; then + echo "Build failed. Exiting..." + exit 1 + fi + echo "Build completed successfully" + echo "" + echo "You can now start the services by running the command: ./setup.sh start" + echo "" +} + function install() { - echo "Installing Plane.........." - download + echo "Begin Installing Plane" + echo "" + + local build_image=$(initialize) + + if [ "$build_image" == "build" ]; then + # ask for confirmation to continue building the images + echo "Do you want to continue with building the Docker images locally?" + read -p "Continue? [y/N]: " confirm + if [[ ! "$confirm" =~ ^[Yy]$ ]]; then + echo "Exiting..." + exit 0 + fi + fi + download $build_image } + function download() { + local build_image=$1 cd $SCRIPT_DIR TS=$(date +%s) if [ -f "$PLANE_INSTALL_DIR/docker-compose.yaml" ] @@ -52,16 +146,16 @@ function download() { mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH fi - # if [ "$BRANCH" != "master" ]; - # then - # cp $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml - # sed -e 's@${APP_RELEASE:-stable}@'"$BRANCH"'@g' \ - # $PLANE_INSTALL_DIR/temp.yaml > $PLANE_INSTALL_DIR/docker-compose.yaml - - # rm $PLANE_INSTALL_DIR/temp.yaml - # fi - - /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull --policy $PULL_POLICY" + if [ "$build_image" == "build" ]; then + buildYourOwnImage + if [ $? -ne 0 ]; then + echo "" + echo "Build failed. Exiting..." + exit 1 + fi + else + /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull --policy $PULL_POLICY" + fi echo "" echo "Most recent Stable version is now available for you to use" @@ -213,7 +307,6 @@ function viewLogs(){ echo "INVALID SERVICE NAME SUPPLIED" fi } - function backupSingleVolume() { backupFolder=$1 selectedVolume=$2 @@ -230,7 +323,6 @@ function backupSingleVolume() { -v "$backupFolder":/backup \ busybox sh -c 'tar -czf "/backup/${TAR_NAME}.tar.gz" /${TAR_NAME}' } - function backupData() { local datetime=$(date +"%Y%m%d-%H%M") local BACKUP_FOLDER=$PLANE_INSTALL_DIR/backup/$datetime @@ -260,7 +352,7 @@ function askForAction() { then echo echo "Select a Action you want to perform:" - echo " 1) Install (${CPU_ARCH})" + echo " 1) Install / Build Your Own Image" echo " 2) Start" echo " 3) Stop" echo " 4) Restart" @@ -282,31 +374,31 @@ function askForAction() { echo fi - if [ "$ACTION" == "1" ] || [ "$DEFAULT_ACTION" == "install" ] + if [ "$ACTION" == "1" ] || [ "$DEFAULT_ACTION" == "install" ]; then install # askForAction - elif [ "$ACTION" == "2" ] || [ "$DEFAULT_ACTION" == "start" ] + elif [ "$ACTION" == "2" ] || [ "$DEFAULT_ACTION" == "start" ]; then startServices # askForAction - elif [ "$ACTION" == "3" ] || [ "$DEFAULT_ACTION" == "stop" ] + elif [ "$ACTION" == "3" ] || [ "$DEFAULT_ACTION" == "stop" ]; then stopServices # askForAction - elif [ "$ACTION" == "4" ] || [ "$DEFAULT_ACTION" == "restart" ] + elif [ "$ACTION" == "4" ] || [ "$DEFAULT_ACTION" == "restart" ]; then restartServices # askForAction - elif [ "$ACTION" == "5" ] || [ "$DEFAULT_ACTION" == "upgrade" ] + elif [ "$ACTION" == "5" ] || [ "$DEFAULT_ACTION" == "upgrade" ]; then upgrade # askForAction - elif [ "$ACTION" == "6" ] || [ "$DEFAULT_ACTION" == "logs" ] + elif [ "$ACTION" == "6" ] || [ "$DEFAULT_ACTION" == "logs" ]; then viewLogs $@ askForAction - elif [ "$ACTION" == "7" ] || [ "$DEFAULT_ACTION" == "backup" ] + elif [ "$ACTION" == "7" ] || [ "$DEFAULT_ACTION" == "backup" ]; then backupData elif [ "$ACTION" == "8" ] @@ -325,48 +417,10 @@ else COMPOSE_CMD="docker compose" fi -# CPU ARCHITECHTURE BASED SETTINGS -CPU_ARCH=$(uname -m) -if [[ $FORCE_CPU == "amd64" || $CPU_ARCH == "amd64" || $CPU_ARCH == "x86_64" || ( $BRANCH == "master" && ( $CPU_ARCH == "arm64" || $CPU_ARCH == "aarch64" ) ) ]]; -then - DOCKERHUB_USER=makeplane - mkdir -p $PLANE_INSTALL_DIR/archive - - if [ "$BRANCH" == "master" ]; - then - export APP_RELEASE=stable - export PULL_POLICY=${PULL_POLICY:-always} - fi - - # REMOVE SPECIAL CHARACTERS FROM BRANCH NAME - if [ "$BRANCH" != "master" ]; - then - if [ $CPU_ARCH != "amd64" && $CPU_ARCH != "x86_64" ]; - then - echo "Since the prebuilt $CPU_ARCH compatible docker images are not available for $BRANCH, you need to build images using build.sh script." - exit 1 - fi - fi -else - echo "$CPU_ARCH is not supported at the moment. Make use of build.sh to build the images locally." - exit 1 -fi - -DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml -DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/plane.env - -# BACKWARD COMPATIBILITY -OLD_DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/.env -if [ -f "$OLD_DOCKER_ENV_PATH" ]; -then - mv "$OLD_DOCKER_ENV_PATH" "$DOCKER_ENV_PATH" - OS_NAME=$(uname) - if [ "$OS_NAME" == "Darwin" ]; - then - sed -i '' -e 's@APP_RELEASE=latest@APP_RELEASE=stable@' "$DOCKER_ENV_PATH" - else - sed -i -e 's@APP_RELEASE=latest@APP_RELEASE=stable@' "$DOCKER_ENV_PATH" - fi +if [ "$CPU_ARCH" == "x86_64" ] || [ "$CPU_ARCH" == "amd64" ]; then + CPU_ARCH="amd64" +elif [ "$CPU_ARCH" == "aarch64" ] || [ "$CPU_ARCH" == "arm64" ]; then + CPU_ARCH="arm64" fi print_header From b1923d1c68b2e6ed09fd6accd58f78c15e346355 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 13:06:57 +0530 Subject: [PATCH 05/15] sync env files during upgrade --- deploy/selfhost/install.sh | 191 ++++++++++++++++++++++++++++------ deploy/selfhost/variables.env | 5 +- 2 files changed, 164 insertions(+), 32 deletions(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index ff8fd8235af..280b6bdd103 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -53,34 +53,121 @@ function spinner() { function initialize(){ printf "Please wait while we check the availability of Docker images for the selected release ($APP_RELEASE) with ${CPU_ARCH^^} support." >&2 - # local IMAGE_NAME=makeplane/plane-proxy - # local IMAGE_TAG=${APP_RELEASE} - # docker manifest inspect ${IMAGE_NAME}:${IMAGE_TAG} | grep -q "\"architecture\": \"${CPU_ARCH}\"" & - # local pid=$! - # spinner $pid - - # echo "" >&2 + if [ "$CUSTOM_BUILD" == "true" ]; then + echo "" >&2 + echo "" >&2 + echo "${CPU_ARCH^^} images are not available for selected release ($APP_RELEASE)." >&2 + echo "build" + return 1 + fi - # wait $pid + local IMAGE_NAME=makeplane/plane-proxy + local IMAGE_TAG=${APP_RELEASE} + docker manifest inspect ${IMAGE_NAME}:${IMAGE_TAG} | grep -q "\"architecture\": \"${CPU_ARCH}\"" & + local pid=$! + spinner $pid + + echo "" >&2 + wait $pid - # if [ $? -eq 0 ]; then - # echo "Plane supports ${CPU_ARCH}" >&2 - # echo "available" - # return 0 - # else + if [ $? -eq 0 ]; then + echo "Plane supports ${CPU_ARCH}" >&2 + echo "available" + return 0 + else echo "" >&2 echo "" >&2 - echo "${CPU_ARCH^^} images are not available for selected release ($APP_RELEASE). Please use the 'Build Your Own Image' option to build the images locally." >&2 + echo "${CPU_ARCH^^} images are not available for selected release ($APP_RELEASE)." >&2 echo "" >&2 echo "build" return 1 - # fi + fi +} +function getEnvValue() { + local key=$1 + local file=$2 + + if [ -z "$key" ] || [ -z "$file" ]; then + echo "Invalid arguments supplied" + exit 1 + fi + + if [ -f "$file" ]; then + grep -q "^$key=" $file + if [ $? -eq 0 ]; then + local value=$(grep "^$key=" $file | cut -d'=' -f2) + echo $value + else + echo "" + fi + fi +} +function updateEnvFile() { + local key=$1 + local value=$2 + local file=$3 + + if [ -z "$key" ] || [ -z "$value" ] || [ -z "$file" ]; then + echo "Invalid arguments supplied" + exit 1 + fi + + if [ -f "$file" ]; then + # check if key exists in the file + grep -q "^$key=" $file + if [ $? -ne 0 ]; then + echo "$key=$value" >> $file + return + else + # if key exists, update the value + sed -i "s/^$key=.*/$key=$value/g" $file + fi + else + echo "File not found: $file" + exit 1 + fi +} + +function updateCustomVariables(){ + echo "Updating custom variables..." >&2 + updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" $DOCKER_ENV_PATH + updateEnvFile "APP_RELEASE" "$APP_RELEASE" $DOCKER_ENV_PATH + updateEnvFile "PULL_POLICY" "$PULL_POLICY" $DOCKER_ENV_PATH + updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" $DOCKER_ENV_PATH + echo "Custom variables updated successfully" >&2 +} + +function syncEnvFile(){ + echo "Syncing environment variables..." >&2 + if [ -f "$PLANE_INSTALL_DIR/plane.env.bak" ]; then + updateCustomVariables + + # READ keys of plane.env and update the values from plane.env.bak + while IFS= read -r line + do + # ignore is the line is empty or starts with # + if [ -z "$line" ] || [[ $line == \#* ]]; then + continue + fi + key=$(echo $line | cut -d'=' -f1) + value=$(getEnvValue $key $PLANE_INSTALL_DIR/plane.env.bak) + if [ -n "$value" ]; then + updateEnvFile $key "$value" $DOCKER_ENV_PATH + fi + done < $DOCKER_ENV_PATH + fi + echo "Environment variables synced successfully" >&2 } function buildYourOwnImage(){ echo "Building images locally..." + export DOCKERHUB_USER="myplane" + export APP_RELEASE="local" + export PULL_POLICY="never" + CUSTOM_BUILD="true" + # checkout the code to ~/tmp/plane folder and build the images local PLANE_TEMP_CODE_DIR=~/tmp/plane rm -rf $PLANE_TEMP_CODE_DIR @@ -91,12 +178,6 @@ function buildYourOwnImage(){ cp $PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml $PLANE_TEMP_CODE_DIR/build.yml cd $PLANE_TEMP_CODE_DIR - if [ "$BRANCH" == "master" ]; - then - export APP_RELEASE=stable - fi - - export DOCKERHUB_USER=myplane /bin/bash -c "$COMPOSE_CMD -f build.yml build --no-cache" >&2 if [ $? -ne 0 ]; then @@ -124,11 +205,16 @@ function install() { exit 0 fi fi - download $build_image + + if [ "$build_image" == "build" ]; then + download "true" + else + download "false" + fi } function download() { - local build_image=$1 + local LOCAL_BUILD=$1 cd $SCRIPT_DIR TS=$(date +%s) if [ -f "$PLANE_INSTALL_DIR/docker-compose.yaml" ] @@ -142,19 +228,37 @@ function download() { if [ -f "$DOCKER_ENV_PATH" ]; then cp $DOCKER_ENV_PATH $PLANE_INSTALL_DIR/archive/$TS.env - else - mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH + cp $DOCKER_ENV_PATH $PLANE_INSTALL_DIR/plane.env.bak fi - if [ "$build_image" == "build" ]; then + mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH + + syncEnvFile + + if [ "$LOCAL_BUILD" == "true" ]; then + export DOCKERHUB_USER="myplane" + export APP_RELEASE="local" + export PULL_POLICY="never" + CUSTOM_BUILD="true" + buildYourOwnImage + if [ $? -ne 0 ]; then echo "" echo "Build failed. Exiting..." exit 1 fi + updateCustomVariables else - /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull --policy $PULL_POLICY" + CUSTOM_BUILD="false" + updateCustomVariables + /bin/bash -c "$COMPOSE_CMD -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH pull --policy always" + + if [ $? -ne 0 ]; then + echo "" + echo "Failed to pull the images. Exiting..." + exit 1 + fi fi echo "" @@ -226,7 +330,7 @@ function upgrade() { echo echo "***** DOWNLOADING STABLE VERSION ****" - download + install echo "***** PLEASE VALIDATE AND START SERVICES ****" } @@ -352,7 +456,7 @@ function askForAction() { then echo echo "Select a Action you want to perform:" - echo " 1) Install / Build Your Own Image" + echo " 1) Install" echo " 2) Start" echo " 3) Stop" echo " 4) Restart" @@ -423,5 +527,32 @@ elif [ "$CPU_ARCH" == "aarch64" ] || [ "$CPU_ARCH" == "arm64" ]; then CPU_ARCH="arm64" fi +if [ -f "$DOCKER_ENV_PATH" ]; then + DOCKERHUB_USER=$(getEnvValue "DOCKERHUB_USER" $DOCKER_ENV_PATH) + APP_RELEASE=$(getEnvValue "APP_RELEASE" $DOCKER_ENV_PATH) + PULL_POLICY=$(getEnvValue "PULL_POLICY" $DOCKER_ENV_PATH) + CUSTOM_BUILD=$(getEnvValue "CUSTOM_BUILD" $DOCKER_ENV_PATH) + + if [ -z "$DOCKERHUB_USER" ]; then + DOCKERHUB_USER=makeplane + updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" $DOCKER_ENV_PATH + fi + + if [ -z "$APP_RELEASE" ]; then + APP_RELEASE=stable + updateEnvFile "APP_RELEASE" "$APP_RELEASE" $DOCKER_ENV_PATH + fi + + if [ -z "$PULL_POLICY" ]; then + PULL_POLICY=if_not_present + updateEnvFile "PULL_POLICY" "$PULL_POLICY" $DOCKER_ENV_PATH + fi + + if [ -z "$CUSTOM_BUILD" ]; then + CUSTOM_BUILD=false + updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" $DOCKER_ENV_PATH + fi +fi + print_header -askForAction $@ +askForAction "$@" diff --git a/deploy/selfhost/variables.env b/deploy/selfhost/variables.env index 08f686c80a4..d009a582298 100644 --- a/deploy/selfhost/variables.env +++ b/deploy/selfhost/variables.env @@ -1,3 +1,4 @@ +APP_DOMAIN=localhost APP_RELEASE=stable WEB_REPLICAS=1 @@ -6,11 +7,11 @@ ADMIN_REPLICAS=1 API_REPLICAS=1 NGINX_PORT=80 -WEB_URL=http://localhost +WEB_URL=http://${APP_DOMAIN} DEBUG=0 SENTRY_DSN= SENTRY_ENVIRONMENT=production -CORS_ALLOWED_ORIGINS=http://localhost +CORS_ALLOWED_ORIGINS=http://${APP_DOMAIN} #DB SETTINGS PGHOST=plane-db From 88f84339c291932490c3a558617e4f75bb76d141 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 13:56:14 +0530 Subject: [PATCH 06/15] updated variables.env --- deploy/selfhost/variables.env | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/selfhost/variables.env b/deploy/selfhost/variables.env index d009a582298..4120ee502aa 100644 --- a/deploy/selfhost/variables.env +++ b/deploy/selfhost/variables.env @@ -47,4 +47,5 @@ FILE_SIZE_LIMIT=5242880 GUNICORN_WORKERS=1 # UNCOMMENT `DOCKER_PLATFORM` IF YOU ARE ON `ARM64` AND DOCKER IMAGE IS NOT AVAILABLE FOR RESPECTIVE `APP_RELEASE` -# DOCKER_PLATFORM=linux/amd64 \ No newline at end of file +# DOCKER_PLATFORM=linux/amd64 + From ff62fb79c31e633291f5fc8a8edb7d655af143b0 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 15:25:46 +0530 Subject: [PATCH 07/15] updated readme --- deploy/selfhost/README.md | 25 ++++--------------------- deploy/selfhost/install.sh | 4 ++-- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index c44771882c7..d93d85ca14d 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -10,7 +10,7 @@ Let's get started!
Option 1 - Using Cloud Server -

Best way to start is to create EC2 maching on AWS. It must of minimum t3.medium/t3a/medium

+

Best way to start is to create EC2 machine on AWS. It must have minimum of 2vCPU and 4GB RAM.

Run the below command to install docker engine.

`curl -fsSL https://get.docker.com | sh -` @@ -67,23 +67,6 @@ curl -fsSL -o setup.sh https://raw.githubusercontent.com/makeplane/plane/master/ chmod +x setup.sh ``` -
- Downloading Preview Release - -``` -mkdir plane-selfhost - -cd plane-selfhost - -export RELEASE=preview - -curl -fsSL https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/install.sh | sed 's@BRANCH=master@BRANCH='"$RELEASE"'@' > setup.sh - -chmod +x setup.sh -``` - -
- --- ### Proceed with setup @@ -114,7 +97,7 @@ This will create a create a folder `plane-app` or `plane-app-preview` (in case o - `docker-compose.yaml` - `plane.env` -Again the `options [1-7]` will be popped up and this time hit `7` to exit. +Again the `options [1-8]` will be popped up and this time hit `8` to exit. --- @@ -236,7 +219,7 @@ Select a Action you want to perform: Action [2]: 5 ``` -By choosing this, it will stop the services and then will download the latest `docker-compose.yaml` and `variables-upgrade.env`. Here system will not replace `.env` with the new one. +By choosing this, it will stop the services and then will download the latest `docker-compose.yaml` and `plane.env`. You must expect the below message @@ -244,7 +227,7 @@ You must expect the below message Once done, choose `8` to exit from prompt. -> It is very important for you to compare the 2 files `variables-upgrade.env` and `.env`. Copy the newly added variable from downloaded file to `.env` and set the expected values. +> It is very important for you to validate the `plane.env` for the new changes. Once done with making changes in `plane.env` file, jump on to `Start Server` diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 280b6bdd103..731673acfcc 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -262,9 +262,9 @@ function download() { fi echo "" - echo "Most recent Stable version is now available for you to use" + echo "Most recent version of Plane is now available for you to use" echo "" - echo "In case of Upgrade, your new setting file is availabe as 'variables-upgrade.env'. Please compare and set the required values in 'plane.env 'file." + echo "In case of 'Upgrade', please check the 'plane.env 'file for any new variables and update them accordingly" echo "" } function startServices() { From 7bae3b5ca98bdcb760bb0e18eaa03ab3019a4964 Mon Sep 17 00:00:00 2001 From: Manish Gupta <59428681+mguptahub@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:43:17 +0530 Subject: [PATCH 08/15] Update deploy/selfhost/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deploy/selfhost/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 731673acfcc..3e8c2c8da5a 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -500,7 +500,7 @@ function askForAction() { # askForAction elif [ "$ACTION" == "6" ] || [ "$DEFAULT_ACTION" == "logs" ]; then - viewLogs $@ + viewLogs "$@" askForAction elif [ "$ACTION" == "7" ] || [ "$DEFAULT_ACTION" == "backup" ]; then From a0edc062c4491c7fb1fdc4cb78a1eb439f3e7693 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 17:28:14 +0530 Subject: [PATCH 09/15] implemented codacy suggestions --- deploy/selfhost/install.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 3e8c2c8da5a..c99899ffb5e 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -131,10 +131,10 @@ function updateEnvFile() { function updateCustomVariables(){ echo "Updating custom variables..." >&2 - updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" $DOCKER_ENV_PATH - updateEnvFile "APP_RELEASE" "$APP_RELEASE" $DOCKER_ENV_PATH - updateEnvFile "PULL_POLICY" "$PULL_POLICY" $DOCKER_ENV_PATH - updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" $DOCKER_ENV_PATH + updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" "$DOCKER_ENV_PATH" + updateEnvFile "APP_RELEASE" "$APP_RELEASE" "$DOCKER_ENV_PATH" + updateEnvFile "PULL_POLICY" "$PULL_POLICY" "$DOCKER_ENV_PATH" + updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" "$DOCKER_ENV_PATH" echo "Custom variables updated successfully" >&2 } @@ -227,8 +227,8 @@ function download() { if [ -f "$DOCKER_ENV_PATH" ]; then - cp $DOCKER_ENV_PATH $PLANE_INSTALL_DIR/archive/$TS.env - cp $DOCKER_ENV_PATH $PLANE_INSTALL_DIR/plane.env.bak + cp "$DOCKER_ENV_PATH" $PLANE_INSTALL_DIR/archive/$TS.env + cp "$DOCKER_ENV_PATH" $PLANE_INSTALL_DIR/plane.env.bak fi mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH @@ -528,29 +528,29 @@ elif [ "$CPU_ARCH" == "aarch64" ] || [ "$CPU_ARCH" == "arm64" ]; then fi if [ -f "$DOCKER_ENV_PATH" ]; then - DOCKERHUB_USER=$(getEnvValue "DOCKERHUB_USER" $DOCKER_ENV_PATH) - APP_RELEASE=$(getEnvValue "APP_RELEASE" $DOCKER_ENV_PATH) - PULL_POLICY=$(getEnvValue "PULL_POLICY" $DOCKER_ENV_PATH) - CUSTOM_BUILD=$(getEnvValue "CUSTOM_BUILD" $DOCKER_ENV_PATH) + DOCKERHUB_USER=$(getEnvValue "DOCKERHUB_USER" "$DOCKER_ENV_PATH") + APP_RELEASE=$(getEnvValue "APP_RELEASE" "$DOCKER_ENV_PATH") + PULL_POLICY=$(getEnvValue "PULL_POLICY" "$DOCKER_ENV_PATH") + CUSTOM_BUILD=$(getEnvValue "CUSTOM_BUILD" "$DOCKER_ENV_PATH") if [ -z "$DOCKERHUB_USER" ]; then DOCKERHUB_USER=makeplane - updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" $DOCKER_ENV_PATH + updateEnvFile "DOCKERHUB_USER" "$DOCKERHUB_USER" "$DOCKER_ENV_PATH" fi if [ -z "$APP_RELEASE" ]; then APP_RELEASE=stable - updateEnvFile "APP_RELEASE" "$APP_RELEASE" $DOCKER_ENV_PATH + updateEnvFile "APP_RELEASE" "$APP_RELEASE" "$DOCKER_ENV_PATH" fi if [ -z "$PULL_POLICY" ]; then PULL_POLICY=if_not_present - updateEnvFile "PULL_POLICY" "$PULL_POLICY" $DOCKER_ENV_PATH + updateEnvFile "PULL_POLICY" "$PULL_POLICY" "$DOCKER_ENV_PATH" fi if [ -z "$CUSTOM_BUILD" ]; then CUSTOM_BUILD=false - updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" $DOCKER_ENV_PATH + updateEnvFile "CUSTOM_BUILD" "$CUSTOM_BUILD" "$DOCKER_ENV_PATH" fi fi From 6860c3823cd23dec6591be1160854a8b34d0d441 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 17:39:01 +0530 Subject: [PATCH 10/15] implemented codacy suggestions --- deploy/selfhost/install.sh | 40 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index c99899ffb5e..8261ad36448 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -40,7 +40,11 @@ function spinner() { local delay=.5 local spinstr='|/-\' - while [ "$(ps a | awk '{print $1}' | grep -w $pid)" ]; do + if ! ps -p "$pid" > /dev/null; then + echo "Invalid PID: $pid" + return 1 + fi + while ps -p "$pid" > /dev/null; do local temp=${spinstr#?} printf " [%c] " "$spinstr" >&2 local spinstr=$temp${spinstr%"$temp"} @@ -63,13 +67,13 @@ function initialize(){ local IMAGE_NAME=makeplane/plane-proxy local IMAGE_TAG=${APP_RELEASE} - docker manifest inspect ${IMAGE_NAME}:${IMAGE_TAG} | grep -q "\"architecture\": \"${CPU_ARCH}\"" & + docker manifest inspect "${IMAGE_NAME}:${IMAGE_TAG}" | grep -q "\"architecture\": \"${CPU_ARCH}\"" & local pid=$! - spinner $pid + spinner "$pid" echo "" >&2 - wait $pid + wait "$pid" if [ $? -eq 0 ]; then echo "Plane supports ${CPU_ARCH}" >&2 @@ -94,10 +98,10 @@ function getEnvValue() { fi if [ -f "$file" ]; then - grep -q "^$key=" $file + grep -q "^$key=" "$file" if [ $? -eq 0 ]; then - local value=$(grep "^$key=" $file | cut -d'=' -f2) - echo $value + local value=$(grep "^$key=" "$file" | cut -d'=' -f2) + echo "$value" else echo "" fi @@ -115,13 +119,13 @@ function updateEnvFile() { if [ -f "$file" ]; then # check if key exists in the file - grep -q "^$key=" $file + grep -q "^$key=" "$file" if [ $? -ne 0 ]; then - echo "$key=$value" >> $file + echo "$key=$value" >> "$file" return else # if key exists, update the value - sed -i "s/^$key=.*/$key=$value/g" $file + sed -i "s/^$key=.*/$key=$value/g" "$file" fi else echo "File not found: $file" @@ -151,11 +155,11 @@ function syncEnvFile(){ continue fi key=$(echo $line | cut -d'=' -f1) - value=$(getEnvValue $key $PLANE_INSTALL_DIR/plane.env.bak) + value=$(getEnvValue "$key" "$PLANE_INSTALL_DIR/plane.env.bak") if [ -n "$value" ]; then - updateEnvFile $key "$value" $DOCKER_ENV_PATH + updateEnvFile "$key" "$value" "$DOCKER_ENV_PATH" fi - done < $DOCKER_ENV_PATH + done < "$DOCKER_ENV_PATH" fi echo "Environment variables synced successfully" >&2 } @@ -173,11 +177,11 @@ function buildYourOwnImage(){ rm -rf $PLANE_TEMP_CODE_DIR mkdir -p $PLANE_TEMP_CODE_DIR REPO=https://github.com/makeplane/plane.git - git clone $REPO $PLANE_TEMP_CODE_DIR --branch $BRANCH --single-branch --depth 1 + git clone "$REPO" "$PLANE_TEMP_CODE_DIR" --branch "$BRANCH" --single-branch --depth 1 - cp $PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml $PLANE_TEMP_CODE_DIR/build.yml + cp "$PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml" "$PLANE_TEMP_CODE_DIR/build.yml" - cd $PLANE_TEMP_CODE_DIR + cd "$PLANE_TEMP_CODE_DIR" /bin/bash -c "$COMPOSE_CMD -f build.yml build --no-cache" >&2 if [ $? -ne 0 ]; then @@ -227,8 +231,8 @@ function download() { if [ -f "$DOCKER_ENV_PATH" ]; then - cp "$DOCKER_ENV_PATH" $PLANE_INSTALL_DIR/archive/$TS.env - cp "$DOCKER_ENV_PATH" $PLANE_INSTALL_DIR/plane.env.bak + cp "$DOCKER_ENV_PATH" "$PLANE_INSTALL_DIR/archive/$TS.env" + cp "$DOCKER_ENV_PATH" "$PLANE_INSTALL_DIR/plane.env.bak" fi mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH From 951b942adab9cfda23b73e22fdc0ec4d261c3d3f Mon Sep 17 00:00:00 2001 From: Manish Gupta <59428681+mguptahub@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:43:07 +0530 Subject: [PATCH 11/15] Update deploy/selfhost/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deploy/selfhost/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 8261ad36448..4a1f0283b9e 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -BRANCH=${BRANCH=master} +BRANCH=${BRANCH:-master} SCRIPT_DIR=$PWD SERVICE_FOLDER=plane-app PLANE_INSTALL_DIR=$PWD/$SERVICE_FOLDER From 14ce2b9c91a2b111f18093a8ad85aed32bee38ea Mon Sep 17 00:00:00 2001 From: Manish Gupta <59428681+mguptahub@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:43:47 +0530 Subject: [PATCH 12/15] Update deploy/selfhost/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deploy/selfhost/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 4a1f0283b9e..5e3159aa708 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -181,7 +181,7 @@ function buildYourOwnImage(){ cp "$PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml" "$PLANE_TEMP_CODE_DIR/build.yml" - cd "$PLANE_TEMP_CODE_DIR" + cd "$PLANE_TEMP_CODE_DIR" || exit /bin/bash -c "$COMPOSE_CMD -f build.yml build --no-cache" >&2 if [ $? -ne 0 ]; then From 65d89bc083d2b5d0001b8d96ad91d8464e3f2201 Mon Sep 17 00:00:00 2001 From: Manish Gupta <59428681+mguptahub@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:46:38 +0530 Subject: [PATCH 13/15] Update deploy/selfhost/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deploy/selfhost/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 5e3159aa708..d8f0ab18df7 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -100,7 +100,8 @@ function getEnvValue() { if [ -f "$file" ]; then grep -q "^$key=" "$file" if [ $? -eq 0 ]; then - local value=$(grep "^$key=" "$file" | cut -d'=' -f2) + local value + value=$(grep "^$key=" "$file" | cut -d'=' -f2) echo "$value" else echo "" From 7af1054be81a12708307a046287542915e9f3544 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 17:54:39 +0530 Subject: [PATCH 14/15] update codacy suggestions --- deploy/selfhost/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index d8f0ab18df7..98aaaf2e763 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -155,7 +155,7 @@ function syncEnvFile(){ if [ -z "$line" ] || [[ $line == \#* ]]; then continue fi - key=$(echo $line | cut -d'=' -f1) + key=$(echo "$line" | cut -d'=' -f1) value=$(getEnvValue "$key" "$PLANE_INSTALL_DIR/plane.env.bak") if [ -n "$value" ]; then updateEnvFile "$key" "$value" "$DOCKER_ENV_PATH" From 8565548241a02e8f75c0ff5a44373da411e4741a Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Thu, 25 Jul 2024 17:55:37 +0530 Subject: [PATCH 15/15] coderabbit suggestion --- deploy/selfhost/install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh index 98aaaf2e763..8fd2e3e2fa1 100755 --- a/deploy/selfhost/install.sh +++ b/deploy/selfhost/install.sh @@ -8,10 +8,6 @@ export APP_RELEASE="stable" export DOCKERHUB_USER=makeplane export PULL_POLICY=${PULL_POLICY:-if_not_present} -RED='\033[0;31m' -YELLOW='\033[1;33m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color CPU_ARCH=$(uname -m) mkdir -p $PLANE_INSTALL_DIR/archive