|
|
@ -1,19 +1,31 @@ |
|
|
|
#!/bin/bash |
|
|
|
#!/bin/bash |
|
|
|
# script to build local docker image. |
|
|
|
# script to build local docker image. |
|
|
|
# highlevel steps involved |
|
|
|
# highlevel steps involved |
|
|
|
# 1. build nocodb-sdk |
|
|
|
# 1. Stop and remove existing container and image |
|
|
|
# 2. build nc-gui |
|
|
|
# 2. Build nocodb-sdk |
|
|
|
# 2a. static build of nc-gui |
|
|
|
# 3. Build nc-gui |
|
|
|
# 2b. copy nc-gui build to nocodb dir |
|
|
|
# 3a. static build of nc-gui |
|
|
|
# 3. build nocodb |
|
|
|
# 3b. copy nc-gui build to nocodb dir |
|
|
|
|
|
|
|
# 4. Build nocodb |
|
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
|
|
|
LOG_FILE=${SCRIPT_DIR}/build-local-docker-image.log |
|
|
|
LOG_FILE=${SCRIPT_DIR}/build-local-docker-image.log |
|
|
|
ERROR="" |
|
|
|
ERROR="" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function stop_and_remove_container() { |
|
|
|
|
|
|
|
# Stop and remove the existing container |
|
|
|
|
|
|
|
docker stop nocodb-local >/dev/null 2>&1 |
|
|
|
|
|
|
|
docker rm nocodb-local >/dev/null 2>&1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function remove_image() { |
|
|
|
|
|
|
|
# Remove the existing image |
|
|
|
|
|
|
|
docker rmi nocodb-local >/dev/null 2>&1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function build_sdk(){ |
|
|
|
function build_sdk(){ |
|
|
|
#build nocodb-sdk |
|
|
|
# build nocodb-sdk |
|
|
|
cd ${SCRIPT_DIR}/packages/nocodb-sdk |
|
|
|
cd ${SCRIPT_DIR}/packages/nocodb-sdk |
|
|
|
npm ci || ERROR="sdk build failed" |
|
|
|
npm ci || ERROR="sdk build failed" |
|
|
|
npm run build || ERROR="sdk build failed" |
|
|
|
npm run build || ERROR="sdk build failed" |
|
|
|
} |
|
|
|
} |
|
|
@ -22,55 +34,59 @@ function build_gui(){ |
|
|
|
# build nc-gui |
|
|
|
# build nc-gui |
|
|
|
export NODE_OPTIONS="--max_old_space_size=16384" |
|
|
|
export NODE_OPTIONS="--max_old_space_size=16384" |
|
|
|
# generate static build of nc-gui |
|
|
|
# generate static build of nc-gui |
|
|
|
cd ${SCRIPT_DIR}/packages/nc-gui |
|
|
|
cd ${SCRIPT_DIR}/packages/nc-gui |
|
|
|
npm ci || ERROR="gui build failed" |
|
|
|
npm ci || ERROR="gui build failed" |
|
|
|
npm run generate || ERROR="gui build failed" |
|
|
|
npm run generate || ERROR="gui build failed" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function copy_gui_artifacts(){ |
|
|
|
function copy_gui_artifacts(){ |
|
|
|
# copy nc-gui build to nocodb dir |
|
|
|
# copy nc-gui build to nocodb dir |
|
|
|
rsync -rvzh --delete ./dist/ ${SCRIPT_DIR}/packages/nocodb/docker/nc-gui/ || ERROR="copy_gui_artifacts failed" |
|
|
|
rsync -rvzh --delete ./dist/ ${SCRIPT_DIR}/packages/nocodb/docker/nc-gui/ || ERROR="copy_gui_artifacts failed" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function package_nocodb(){ |
|
|
|
function package_nocodb(){ |
|
|
|
#build nocodb |
|
|
|
#build nocodb |
|
|
|
# build nocodb ( pack nocodb-sdk and nc-gui ) |
|
|
|
# build nocodb ( pack nocodb-sdk and nc-gui ) |
|
|
|
cd ${SCRIPT_DIR}/packages/nocodb |
|
|
|
cd ${SCRIPT_DIR}/packages/nocodb |
|
|
|
npm install || ERROR="package_nocodb failed" |
|
|
|
npm install || ERROR="package_nocodb failed" |
|
|
|
EE=true ./node_modules/.bin/webpack --config webpack.local.config.js || ERROR="package_nocodb failed" |
|
|
|
EE=true ./node_modules/.bin/webpack --config webpack.local.config.js || ERROR="package_nocodb failed" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function build_image(){ |
|
|
|
function build_image(){ |
|
|
|
# build docker |
|
|
|
# build docker |
|
|
|
docker build . -f Dockerfile.local -t nocodb-local || ERROR="build_image failed" |
|
|
|
docker build . -f Dockerfile.local -t nocodb-local || ERROR="build_image failed" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function log_message(){ |
|
|
|
function log_message(){ |
|
|
|
if [[ ${ERROR} != "" ]]; |
|
|
|
if [[ ${ERROR} != "" ]]; |
|
|
|
then |
|
|
|
then |
|
|
|
>&2 echo "build failed, Please check build-local-docker-image.log for more details" |
|
|
|
>&2 echo "build failed, Please check build-local-docker-image.log for more details" |
|
|
|
>&2 echo "ERROR: ${ERROR}" |
|
|
|
>&2 echo "ERROR: ${ERROR}" |
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
|
else |
|
|
|
else |
|
|
|
echo 'docker image with tag "nocodb-local" built sussessfully. Use below sample command to run the container' |
|
|
|
echo 'docker image with tag "nocodb-local" built sussessfully. Use below sample command to run the container' |
|
|
|
echo 'docker run -d -p 3333:8080 --name nocodb-local nocodb-local ' |
|
|
|
echo 'docker run -d -p 3333:8080 --name nocodb-local nocodb-local ' |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
echo "Info: Building nocodb-sdk" | tee ${LOG_FILE} |
|
|
|
echo "Info: Stopping and removing existing container and image" | tee ${LOG_FILE} |
|
|
|
|
|
|
|
stop_and_remove_container |
|
|
|
|
|
|
|
remove_image |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Info: Building nocodb-sdk" | tee -a ${LOG_FILE} |
|
|
|
build_sdk 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
build_sdk 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
|
|
|
|
|
|
|
|
echo "Info: Building nc-gui" | tee -a ${LOG_FILE} |
|
|
|
echo "Info: Building nc-gui" | tee -a ${LOG_FILE} |
|
|
|
build_gui 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
build_gui 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
|
|
|
|
|
|
|
|
echo "Info: copy nc-gui build to nocodb dir" | tee -a ${LOG_FILE} |
|
|
|
echo "Info: Copy nc-gui build to nocodb dir" | tee -a ${LOG_FILE} |
|
|
|
copy_gui_artifacts 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
copy_gui_artifacts 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
|
|
|
|
|
|
|
|
echo "Info: build nocodb, package nocodb-sdk and nc-gui" | tee -a ${LOG_FILE} |
|
|
|
echo "Info: Build nocodb, package nocodb-sdk and nc-gui" | tee -a ${LOG_FILE} |
|
|
|
package_nocodb 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
package_nocodb 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
|
|
|
|
|
|
|
|
if [[ ${ERROR} == "" ]]; then |
|
|
|
if [[ ${ERROR} == "" ]]; then |
|
|
|
echo "Info: building docker image" | tee -a ${LOG_FILE} |
|
|
|
echo "Info: Building docker image" | tee -a ${LOG_FILE} |
|
|
|
build_image 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
build_image 1>> ${LOG_FILE} 2>> ${LOG_FILE} |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|