From f34eedd0870ee1075f2c609df6412ee2d59533dd Mon Sep 17 00:00:00 2001 From: Yibai Zhang Date: Mon, 28 Nov 2016 12:22:26 +0800 Subject: [PATCH] Add config file to let users modify config easily. --- config | 18 ++++++++++++++++++ ide.sh | 32 +++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 config diff --git a/config b/config new file mode 100644 index 0000000..26fa31d --- /dev/null +++ b/config @@ -0,0 +1,18 @@ +# Environment for running the application, either "prod" or "dev" +#RUN_ENV= + +# USER INFO +#USERNAME= +#EMAIL= +#AVATAR= + +# CORS (Seprate with comma) +#ALLOWED_ORIGINS= + +# Home Directory(Do not modify when using docker) +#CODING_IDE_HOME= +#SPACE_HOME= + +# Max file size to upload (in Mb) +#UPLOAD_FILE_SIZE_LIMIT= + diff --git a/ide.sh b/ide.sh index 482055c..96faf38 100755 --- a/ide.sh +++ b/ide.sh @@ -62,21 +62,37 @@ do_build_frontend() { cd $BASEDIR } +do_build_backend() { + cd $BACKEND + echo "mvn clean and packaging..." + mvn clean package -Dmaven.test.skip=true + valid_last_cmd + cd $BASEDIR +} + sub_build() { build_usage() { - echo "Usage: $PROG_NAME build frontend" + echo "Usage: $PROG_NAME build [frontend | backend | run]" } case $1 in "-h" | "--help") build_usage ;; - "" | "frontend") + "") + do_build_frontend + do_build_backend + ;; + "backend") + do_build_backend + ;; + "frontend") do_build_frontend ;; "run") # build and run do_build_frontend + do_build_backend do_run_backend ;; esac @@ -193,7 +209,7 @@ sub_docker() { create_dir_if_not_exist $HOME/.coding-ide-home echo "creating container $CONTAINER" - docker create -p 8080:8080 -v $HOME/.coding-ide-home:/home/coding/coding-ide-home --name webide -h webide webide/webide + docker create -p 8080:8080 --env-file config -v $HOME/.coding-ide-home:/home/coding/coding-ide-home --name webide -h webide webide/webide valid_last_cmd elif [ "$RUNNING" == "true" ]; then echo "CRITICAL - $CONTAINER is running." @@ -234,9 +250,11 @@ sub_docker() { } do_run_backend() { - cd $BACKEND - mvn clean && mvn spring-boot:run ${1} - cd $BASEDIR + if [ ! -f $BACKEND/target/ide-backend.jar ]; then + sub_build + fi + . $BASEDIR/config + java -jar $BACKEND/target/ide-backend.jar --PTY_LIB_FOLDER=$BACKEND/src/main/resources/lib ${1} } sub_run() { @@ -250,7 +268,7 @@ sub_run() { while getopts ":p:" opt; do case $opt in p) - EXTRA_VARS=-Drun.arguments="--server.port=${OPTARG}" + EXTRA_VARS="--server.port=${OPTARG}" ;; \?) run_usage