Chore: self host enhancements (#4091)

* latest changed to stable and .env changed to plane.env

* env changes

* script fix

* env changes

* sed fix

* codacy proposed fixes
This commit is contained in:
Manish Gupta 2024-03-28 15:53:37 +05:30 committed by GitHub
parent 97fb08928f
commit 86715f5b20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 73 additions and 45 deletions

View File

@ -5,11 +5,11 @@ x-app-env: &app-env
- NGINX_PORT=${NGINX_PORT:-80} - NGINX_PORT=${NGINX_PORT:-80}
- WEB_URL=${WEB_URL:-http://localhost} - WEB_URL=${WEB_URL:-http://localhost}
- DEBUG=${DEBUG:-0} - DEBUG=${DEBUG:-0}
- SENTRY_DSN=${SENTRY_DSN:-""} - SENTRY_DSN=${SENTRY_DSN}
- SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT:-"production"} - SENTRY_ENVIRONMENT=${SENTRY_ENVIRONMENT:-"production"}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-""} - CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS}
# Gunicorn Workers # Gunicorn Workers
- GUNICORN_WORKERS=${GUNICORN_WORKERS:-2} - GUNICORN_WORKERS=${GUNICORN_WORKERS:-1}
#DB SETTINGS #DB SETTINGS
- PGHOST=${PGHOST:-plane-db} - PGHOST=${PGHOST:-plane-db}
- PGDATABASE=${PGDATABASE:-plane} - PGDATABASE=${PGDATABASE:-plane}
@ -17,11 +17,11 @@ x-app-env: &app-env
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-plane} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-plane}
- POSTGRES_DB=${POSTGRES_DB:-plane} - POSTGRES_DB=${POSTGRES_DB:-plane}
- PGDATA=${PGDATA:-/var/lib/postgresql/data} - PGDATA=${PGDATA:-/var/lib/postgresql/data}
- DATABASE_URL=${DATABASE_URL:-postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${PGHOST}/${PGDATABASE}} - DATABASE_URL=${DATABASE_URL:-postgresql://plane:plane@plane-db/plane}
# REDIS SETTINGS # REDIS SETTINGS
- REDIS_HOST=${REDIS_HOST:-plane-redis} - REDIS_HOST=${REDIS_HOST:-plane-redis}
- REDIS_PORT=${REDIS_PORT:-6379} - REDIS_PORT=${REDIS_PORT:-6379}
- REDIS_URL=${REDIS_URL:-redis://${REDIS_HOST}:6379/} - REDIS_URL=${REDIS_URL:-redis://plane-redis:6379/}
# Application secret # Application secret
- SECRET_KEY=${SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5} - SECRET_KEY=${SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}
# DATA STORE SETTINGS # DATA STORE SETTINGS
@ -39,7 +39,7 @@ x-app-env: &app-env
services: services:
web: web:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-frontend:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-frontend:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped restart: unless-stopped
command: /usr/local/bin/start.sh web/server.js web command: /usr/local/bin/start.sh web/server.js web
@ -51,7 +51,7 @@ services:
space: space:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-space:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-space:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped restart: unless-stopped
command: /usr/local/bin/start.sh space/server.js space command: /usr/local/bin/start.sh space/server.js space
@ -64,7 +64,7 @@ services:
api: api:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped restart: unless-stopped
command: ./bin/takeoff command: ./bin/takeoff
@ -78,7 +78,7 @@ services:
worker: worker:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped restart: unless-stopped
command: ./bin/worker command: ./bin/worker
@ -91,7 +91,7 @@ services:
beat-worker: beat-worker:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped restart: unless-stopped
command: ./bin/beat command: ./bin/beat
@ -104,7 +104,7 @@ services:
migrator: migrator:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
restart: no restart: no
command: > command: >
@ -118,7 +118,7 @@ services:
plane-db: plane-db:
<<: *app-env <<: *app-env
image: postgres:15.2-alpine image: postgres:15.5-alpine
pull_policy: if_not_present pull_policy: if_not_present
restart: unless-stopped restart: unless-stopped
command: postgres -c 'max_connections=1000' command: postgres -c 'max_connections=1000'
@ -126,7 +126,7 @@ services:
- pgdata:/var/lib/postgresql/data - pgdata:/var/lib/postgresql/data
plane-redis: plane-redis:
<<: *app-env <<: *app-env
image: redis:6.2.7-alpine image: redis:7.2.4-alpine
pull_policy: if_not_present pull_policy: if_not_present
restart: unless-stopped restart: unless-stopped
volumes: volumes:
@ -144,7 +144,7 @@ services:
# Comment this if you already have a reverse proxy running # Comment this if you already have a reverse proxy running
proxy: proxy:
<<: *app-env <<: *app-env
image: ${DOCKERHUB_USER:-makeplane}/plane-proxy:${APP_RELEASE:-latest} image: ${DOCKERHUB_USER:-makeplane}/plane-proxy:${APP_RELEASE:-stable}
pull_policy: ${PULL_POLICY:-always} pull_policy: ${PULL_POLICY:-always}
ports: ports:
- ${NGINX_PORT}:80 - ${NGINX_PORT}:80

View File

@ -17,16 +17,16 @@ function print_header() {
clear clear
cat <<"EOF" cat <<"EOF"
--------------------------------------- --------------------------------------------
____ _ ____ _ /////////
| _ \| | __ _ _ __ ___ | _ \| | __ _ _ __ ___ /////////
| |_) | |/ _` | '_ \ / _ \ | |_) | |/ _` | '_ \ / _ \ ///// /////
| __/| | (_| | | | | __/ | __/| | (_| | | | | __/ ///// /////
|_| |_|\__,_|_| |_|\___| |_| |_|\__,_|_| |_|\___| ////
////
--------------------------------------- --------------------------------------------
Project management tool from the future Project management tool from the future
--------------------------------------- --------------------------------------------
EOF EOF
} }
@ -66,7 +66,7 @@ function buildLocalImage() {
cd $PLANE_TEMP_CODE_DIR cd $PLANE_TEMP_CODE_DIR
if [ "$BRANCH" == "master" ]; if [ "$BRANCH" == "master" ];
then then
export APP_RELEASE=latest export APP_RELEASE=stable
fi fi
docker compose -f build.yml build --no-cache >&2 docker compose -f build.yml build --no-cache >&2
@ -99,17 +99,17 @@ function download() {
curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/docker-compose.yaml https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/docker-compose.yml?$(date +%s) curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/docker-compose.yaml https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/docker-compose.yml?$(date +%s)
curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/variables-upgrade.env https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/variables.env?$(date +%s) curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/variables-upgrade.env https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/variables.env?$(date +%s)
if [ -f "$PLANE_INSTALL_DIR/.env" ]; if [ -f "$DOCKER_ENV_PATH" ];
then then
cp $PLANE_INSTALL_DIR/.env $PLANE_INSTALL_DIR/archive/$TS.env cp $DOCKER_ENV_PATH $PLANE_INSTALL_DIR/archive/$TS.env
else else
mv $PLANE_INSTALL_DIR/variables-upgrade.env $PLANE_INSTALL_DIR/.env mv $PLANE_INSTALL_DIR/variables-upgrade.env $DOCKER_ENV_PATH
fi fi
if [ "$BRANCH" != "master" ]; if [ "$BRANCH" != "master" ];
then then
cp $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml cp $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml
sed -e 's@${APP_RELEASE:-latest}@'"$BRANCH"'@g' \ sed -e 's@${APP_RELEASE:-stable}@'"$BRANCH"'@g' \
$PLANE_INSTALL_DIR/temp.yaml > $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/temp.yaml > $PLANE_INSTALL_DIR/docker-compose.yaml
rm $PLANE_INSTALL_DIR/temp.yaml rm $PLANE_INSTALL_DIR/temp.yaml
@ -131,9 +131,9 @@ function download() {
fi fi
echo "" echo ""
echo "Latest version is now available for you to use" echo "Most recent Stable version is now available for you to use"
echo "" echo ""
echo "In case of Upgrade, your new setting file is availabe as 'variables-upgrade.env'. Please compare and set the required values in '.env 'file." 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 "" echo ""
} }
@ -144,7 +144,7 @@ function startServices() {
if [ -n "$migrator_container_id" ]; then if [ -n "$migrator_container_id" ]; then
local idx=0 local idx=0
while docker inspect --format='{{.State.Status}}' $migrator_container_id | grep -q "running"; do while docker inspect --format='{{.State.Status}}' $migrator_container_id | grep -q "running"; do
local message=">>> Waiting for Data Migration to finish" local message=">> Waiting for Data Migration to finish"
local dots=$(printf '%*s' $idx | tr ' ' '.') local dots=$(printf '%*s' $idx | tr ' ' '.')
echo -ne "\r$message$dots" echo -ne "\r$message$dots"
((idx++)) ((idx++))
@ -152,13 +152,18 @@ function startServices() {
done done
fi fi
printf "\r\033[K" printf "\r\033[K"
echo ""
echo " Data Migration completed successfully ✅"
# if migrator exit status is not 0, show error message and exit # if migrator exit status is not 0, show error message and exit
if [ -n "$migrator_container_id" ]; then if [ -n "$migrator_container_id" ]; then
local migrator_exit_code=$(docker inspect --format='{{.State.ExitCode}}' $migrator_container_id) local migrator_exit_code=$(docker inspect --format='{{.State.ExitCode}}' $migrator_container_id)
if [ $migrator_exit_code -ne 0 ]; then if [ $migrator_exit_code -ne 0 ]; then
echo "Plane Server failed to start ❌" echo "Plane Server failed to start ❌"
stopServices # stopServices
echo
echo "Please check the logs for the 'migrator' service and resolve the issue(s)."
echo "Stop the services by running the command: ./setup.sh stop"
exit 1 exit 1
fi fi
fi fi
@ -167,26 +172,35 @@ function startServices() {
local idx2=0 local idx2=0
while ! docker logs $api_container_id 2>&1 | grep -m 1 -i "Application startup complete" | grep -q "."; while ! docker logs $api_container_id 2>&1 | grep -m 1 -i "Application startup complete" | grep -q ".";
do do
local message=">>> Waiting for API Service to Start" local message=">> Waiting for API Service to Start"
local dots=$(printf '%*s' $idx2 | tr ' ' '.') local dots=$(printf '%*s' $idx2 | tr ' ' '.')
echo -ne "\r$message$dots" echo -ne "\r$message$dots"
((idx2++)) ((idx2++))
sleep 1 sleep 1
done done
printf "\r\033[K" printf "\r\033[K"
echo " API Service started successfully ✅"
source "${DOCKER_ENV_PATH}"
echo " Plane Server started successfully ✅"
echo ""
echo " You can access the application at $WEB_URL"
echo ""
} }
function stopServices() { function stopServices() {
docker compose -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH down docker compose -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH down
} }
function restartServices() { function restartServices() {
docker compose -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH restart # docker compose -f $DOCKER_FILE_PATH --env-file=$DOCKER_ENV_PATH restart
stopServices
startServices
} }
function upgrade() { function upgrade() {
echo "***** STOPPING SERVICES ****" echo "***** STOPPING SERVICES ****"
stopServices stopServices
echo echo
echo "***** DOWNLOADING LATEST VERSION ****" echo "***** DOWNLOADING STABLE VERSION ****"
download download
echo "***** PLEASE VALIDATE AND START SERVICES ****" echo "***** PLEASE VALIDATE AND START SERVICES ****"
@ -303,15 +317,15 @@ function askForAction() {
elif [ "$ACTION" == "2" ] || [ "$DEFAULT_ACTION" == "start" ] elif [ "$ACTION" == "2" ] || [ "$DEFAULT_ACTION" == "start" ]
then then
startServices startServices
askForAction # askForAction
elif [ "$ACTION" == "3" ] || [ "$DEFAULT_ACTION" == "stop" ] elif [ "$ACTION" == "3" ] || [ "$DEFAULT_ACTION" == "stop" ]
then then
stopServices stopServices
askForAction # askForAction
elif [ "$ACTION" == "4" ] || [ "$DEFAULT_ACTION" == "restart" ] elif [ "$ACTION" == "4" ] || [ "$DEFAULT_ACTION" == "restart" ]
then then
restartServices restartServices
askForAction # askForAction
elif [ "$ACTION" == "5" ] || [ "$DEFAULT_ACTION" == "upgrade" ] elif [ "$ACTION" == "5" ] || [ "$DEFAULT_ACTION" == "upgrade" ]
then then
upgrade upgrade
@ -343,7 +357,7 @@ fi
if [ "$BRANCH" == "master" ]; if [ "$BRANCH" == "master" ];
then then
export APP_RELEASE=latest export APP_RELEASE=stable
fi fi
# REMOVE SPECIAL CHARACTERS FROM BRANCH NAME # REMOVE SPECIAL CHARACTERS FROM BRANCH NAME
@ -354,7 +368,21 @@ fi
mkdir -p $PLANE_INSTALL_DIR/archive mkdir -p $PLANE_INSTALL_DIR/archive
DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml
DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/.env 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
fi
print_header print_header
askForAction $@ askForAction $@

View File

@ -1,4 +1,4 @@
APP_RELEASE=latest APP_RELEASE=stable
WEB_REPLICAS=1 WEB_REPLICAS=1
SPACE_REPLICAS=1 SPACE_REPLICAS=1
@ -18,12 +18,12 @@ POSTGRES_USER=plane
POSTGRES_PASSWORD=plane POSTGRES_PASSWORD=plane
POSTGRES_DB=plane POSTGRES_DB=plane
PGDATA=/var/lib/postgresql/data PGDATA=/var/lib/postgresql/data
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${PGHOST}/${PGDATABASE} DATABASE_URL=
# REDIS SETTINGS # REDIS SETTINGS
REDIS_HOST=plane-redis REDIS_HOST=plane-redis
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_URL=redis://${REDIS_HOST}:6379/ REDIS_URL=
# Secret Key # Secret Key
SECRET_KEY=60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5 SECRET_KEY=60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5
@ -41,4 +41,4 @@ BUCKET_NAME=uploads
FILE_SIZE_LIMIT=5242880 FILE_SIZE_LIMIT=5242880
# Gunicorn Workers # Gunicorn Workers
GUNICORN_WORKERS=2 GUNICORN_WORKERS=1

View File

@ -30,7 +30,7 @@ http {
} }
location /${BUCKET_NAME}/ { location /${BUCKET_NAME}/ {
proxy_pass http://plane-minio:9000/uploads/; proxy_pass http://plane-minio:9000/${BUCKET_NAME}/;
} }
} }
} }