Skip to content

Commit

Permalink
dev: self host local build for other arch cpu (#3358)
Browse files Browse the repository at this point in the history
handled x86_64 along with amd64
  • Loading branch information
mguptahub authored and sriramveeraghanta committed Jan 22, 2024
1 parent 4b0d855 commit 4ab64b6
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 23 deletions.
26 changes: 26 additions & 0 deletions deploy/selfhost/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.8"

services:
web:
image: ${DOCKERHUB_USER:-local}/plane-frontend:${APP_RELEASE:-latest}
build:
context: .
dockerfile: ./web/Dockerfile.web

space:
image: ${DOCKERHUB_USER:-local}/plane-space:${APP_RELEASE:-latest}
build:
context: ./
dockerfile: ./space/Dockerfile.space

api:
image: ${DOCKERHUB_USER:-local}/plane-backend:${APP_RELEASE:-latest}
build:
context: ./apiserver
dockerfile: ./Dockerfile.api

proxy:
image: ${DOCKERHUB_USER:-local}/plane-proxy:${APP_RELEASE:-latest}
build:
context: ./nginx
dockerfile: ./Dockerfile
27 changes: 15 additions & 12 deletions deploy/selfhost/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ x-app-env : &app-env
services:
web:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-frontend:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-frontend:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped
command: /usr/local/bin/start.sh web/server.js web
deploy:
Expand All @@ -77,8 +77,8 @@ services:

space:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-space:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-space:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped
command: /usr/local/bin/start.sh space/server.js space
deploy:
Expand All @@ -90,8 +90,8 @@ services:

api:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-backend:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped
command: ./bin/takeoff
deploy:
Expand All @@ -102,8 +102,8 @@ services:

worker:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-backend:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped
command: ./bin/worker
depends_on:
Expand All @@ -113,8 +113,8 @@ services:

beat-worker:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-backend:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-backend:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
restart: unless-stopped
command: ./bin/beat
depends_on:
Expand All @@ -125,6 +125,7 @@ services:
plane-db:
<<: *app-env
image: postgres:15.2-alpine
pull_policy: if_not_present
restart: unless-stopped
command: postgres -c 'max_connections=1000'
volumes:
Expand All @@ -133,13 +134,15 @@ services:
plane-redis:
<<: *app-env
image: redis:6.2.7-alpine
pull_policy: if_not_present
restart: unless-stopped
volumes:
- redisdata:/data

plane-minio:
<<: *app-env
image: minio/minio
pull_policy: if_not_present
restart: unless-stopped
command: server /export --console-address ":9090"
volumes:
Expand All @@ -148,8 +151,8 @@ services:
# Comment this if you already have a reverse proxy running
proxy:
<<: *app-env
platform: linux/amd64
image: makeplane/plane-proxy:${APP_RELEASE:-latest}
image: ${DOCKERHUB_USER:-makeplane}/plane-proxy:${APP_RELEASE:-latest}
pull_policy: ${PULL_POLICY:-always}
ports:
- ${NGINX_PORT}:80
depends_on:
Expand Down
113 changes: 102 additions & 11 deletions deploy/selfhost/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,75 @@
BRANCH=master
SCRIPT_DIR=$PWD
PLANE_INSTALL_DIR=$PWD/plane-app
export APP_RELEASE=$BRANCH
export DOCKERHUB_USER=makeplane
export PULL_POLICY=always
USE_GLOBAL_IMAGES=1

function install(){
echo
echo "Installing on $PLANE_INSTALL_DIR"
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

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 ${ARCH} cpu architecture. ${NC}\n" >&2
printf "${YELLOW}Since the prebuilt ${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
APP_RELEASE=latest
fi

docker compose -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
}
function download(){
function download() {
cd $SCRIPT_DIR
TS=$(date +%s)
if [ -f "$PLANE_INSTALL_DIR/docker-compose.yaml" ]
Expand All @@ -35,6 +97,21 @@ function download(){

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
docker compose -f $PLANE_INSTALL_DIR/docker-compose.yaml pull
fi

echo ""
echo "Latest version is now available for you to use"
Expand All @@ -43,22 +120,22 @@ function download(){
echo ""

}
function startServices(){
function startServices() {
cd $PLANE_INSTALL_DIR
docker compose up -d
docker compose up -d --quiet-pull
cd $SCRIPT_DIR
}
function stopServices(){
function stopServices() {
cd $PLANE_INSTALL_DIR
docker compose down
cd $SCRIPT_DIR
}
function restartServices(){
function restartServices() {
cd $PLANE_INSTALL_DIR
docker compose restart
cd $SCRIPT_DIR
}
function upgrade(){
function upgrade() {
echo "***** STOPPING SERVICES ****"
stopServices

Expand All @@ -69,10 +146,10 @@ function upgrade(){
echo "***** PLEASE VALIDATE AND START SERVICES ****"

}
function askForAction(){
function askForAction() {
echo
echo "Select a Action you want to perform:"
echo " 1) Install"
echo " 1) Install (${ARCH})"
echo " 2) Start"
echo " 3) Stop"
echo " 4) Restart"
Expand Down Expand Up @@ -115,6 +192,20 @@ function askForAction(){
fi
}

# CPU ARCHITECHTURE BASED SETTINGS
ARCH=$(uname -m)
if [ $ARCH == "amd64" ] || [ $ARCH == "x86_64" ];
then
USE_GLOBAL_IMAGES=1
DOCKERHUB_USER=makeplane
PULL_POLICY=always
else
USE_GLOBAL_IMAGES=0
DOCKERHUB_USER=myplane
PULL_POLICY=never
fi

# REMOVE SPECIAL CHARACTERS FROM BRANCH NAME
if [ "$BRANCH" != "master" ];
then
PLANE_INSTALL_DIR=$PWD/plane-app-$(echo $BRANCH | sed -r 's@(\/|" "|\.)@-@g')
Expand Down

0 comments on commit 4ab64b6

Please sign in to comment.