diff --git a/README.md b/README.md index 020d4c9e9..c87acedbc 100644 --- a/README.md +++ b/README.md @@ -307,9 +307,15 @@ The sceond step is simply: ``` The script `build-and-deploy-webapp.sh` puts it altogether and will eventually launch a Tomcat container with a running -dev instance of Single Cell Expression Atlas. +dev instance of Single Cell Expression Atlas. The script before launching the web application can build only the back-end or front-end component or both. +Here is the usage of this script: + - -f Use this flag if you would like to build the front-end javascript packages. + - -b Use this flag if you would like to build the back-end of the web application. + - -h Displaying the help file of this script. + +If you don't give any flags, or you add both then the script is going to build both front and back-end part of the web application. ### Gradle shell It diff --git a/build-and-deploy-webapp.sh b/build-and-deploy-webapp.sh index d117d883d..16e36f13a 100755 --- a/build-and-deploy-webapp.sh +++ b/build-and-deploy-webapp.sh @@ -5,13 +5,57 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ENV_FILE=${SCRIPT_DIR}/docker/dev.env source ${ENV_FILE} +function show_usage { + echo "Usage: build-and-deploy-webapp.sh [OPTION]..." + echo "It is building and deploying our web application." + echo "" + echo "All options are disabled if omitted." + echo -e "-f\tUse this flag if you would like to build the front-end javascript packages." + echo -e "-b\tUse this flag if you would like to build the back-end of the web application." + echo -e "-h\tDisplaying this help file." + echo -e "\nIf you don't give any flags or you add both then the script is going to build both front and back-end part of the web application." +} + +function get_build_type() { + if [[ $BUILD_FRONTEND == "true" && $BUILD_BACKEND != "true" ]]; then + echo "-ui-only" + elif [[ $BUILD_FRONTEND != "true" && $BUILD_BACKEND == "true" ]]; then + echo "-war-only" + elif [[ $BUILD_FRONTEND == "true" && $BUILD_BACKEND == "true" ]] || [[ -z $BUILD_FRONTEND && -z $BUILD_BACKEND ]]; then + echo "-all" + fi +} + +while getopts ":fbh" opt; do + case $opt in + f) + BUILD_FRONTEND=true + ;; + b) + BUILD_BACKEND=true + ;; + h) + show_usage + exit 1 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + echo "" + show_usage + exit 1 + ;; + esac +done + +BUILD_POSTFIX=$(get_build_type) + DOCKER_COMPOSE_COMMAND="docker compose \ --project-name ${PROJECT_NAME} \ --env-file=${ENV_FILE} \ -f ./docker/docker-compose-solrcloud.yml \ -f ./docker/docker-compose-postgres.yml \ -f ./docker/docker-compose-tomcat.yml \ --f ./docker/docker-compose-build.yml" +-f ./docker/docker-compose-build${BUILD_POSTFIX}.yml" DOCKER_COMPOSE_COMMAND_VARS="SCHEMA_VERSION=latest" diff --git a/docker/docker-compose-build.yml b/docker/docker-compose-build-all.yml similarity index 100% rename from docker/docker-compose-build.yml rename to docker/docker-compose-build-all.yml diff --git a/docker/docker-compose-build-ui-only.yml b/docker/docker-compose-build-ui-only.yml new file mode 100644 index 000000000..7e9e4c97e --- /dev/null +++ b/docker/docker-compose-build-ui-only.yml @@ -0,0 +1,42 @@ +version: "3.6" + +services: + node-webpack: + image: node:16 + volumes: + - ..:/root/project + working_dir: /root/project + command: ["sh", "-c", "export CPPFLAGS=-DPNG_ARM_NEON_OPT=0 && npm install -g npm-check-updates && ./compile-front-end-packages.sh -ui" ] + + gradle-build: + depends_on: + node-webpack: + condition: service_completed_successfully + extends: + service: gradle + file: docker-compose-gradle.yml + + gradle-shell: + extends: + service: gradle + file: docker-compose-gradle.yml + tty: true + stdin_open: true + command: [ "sh", "-c", "gradle && /bin/bash" ] + depends_on: + gradle-build: + condition: service_completed_successfully + + tomcat: + extends: + service: tomcat + file: docker-compose-tomcat.yml + depends_on: + gradle-build: + condition: service_completed_successfully + postgres: + condition: service_started + solrcloud-0: + condition: service_started + solrcloud-1: + condition: service_started diff --git a/docker/docker-compose-build-war-only.yml b/docker/docker-compose-build-war-only.yml new file mode 100644 index 000000000..4749ce6fc --- /dev/null +++ b/docker/docker-compose-build-war-only.yml @@ -0,0 +1,33 @@ +version: "3.6" + +services: + gradle-build: + extends: + service: gradle + file: docker-compose-gradle.yml + command: ["sh", "-c", "gradle clean :app:war"] + + gradle-shell: + extends: + service: gradle + file: docker-compose-gradle.yml + tty: true + stdin_open: true + command: [ "sh", "-c", "gradle && /bin/bash" ] + depends_on: + gradle-build: + condition: service_completed_successfully + + tomcat: + extends: + service: tomcat + file: docker-compose-tomcat.yml + depends_on: + gradle-build: + condition: service_completed_successfully + postgres: + condition: service_started + solrcloud-0: + condition: service_started + solrcloud-1: + condition: service_started