#!/usr/bin/env bash build_webpack=false run_install=false show_help() { echo "Start The script for starting the web app. This script calls the necessary commands to start the web app containers from their built images. Usage: start.sh [OPTIONS] Options: -b|--build-webpack: Builds the frontend webpack before starting the web app docker containers. -i|--npm-install: Runs an npm install before building the frontend webpack. -h|--help: Shows this help message. " } while [[ "$#" -gt 0 ]]; do case "$1" in -b|--build-webpack) build_webpack=true shift 1 ;; -i|--npm-install) run_install=true shift 1 ;; -h|--help) show_help exit ;; *) echo "Invalid argument given ($1)" exit 1 ;; esac done cur_dir="$(cd "$( dirname "$0")" && pwd)" required_files=("$cur_dir/docker/env" "$cur_dir/docker/mongo-init.js") line_sep="===============================" for file in "${required_files[@]}"; do if [[ ! -f "$file" ]]; then echo "A required file is missing (did you run create_env.py and render_docker_templates.sh?). Missing file path: \"$file\"" exit 1 fi done if "$build_webpack"; then build_cmd="$cur_dir/scripts/build_frontend_webpack.sh" if "$run_install"; then build_cmd="$build_cmd --npm-install" fi echo "$line_sep" echo "Running frontend build script ($build_cmd)" echo "$line_sep" $build_cmd else echo "" echo "$line_sep" echo "Not building webpack" echo "$line_sep " fi # if there is no built webpack, don't start the containers if [[ ! -d "$cur_dir/quarterformsdist" ]]; then echo "The webpack does not appear to be built (run with --build-webpack to build it)." exit 1 elif [[ ! -f "$cur_dir/quarterformsdist/index.html" ]]; then echo "There is no index.html in the webpack build directory!" exit 1 fi sudo docker-compose -f "$cur_dir/docker/docker-compose.yaml" up -d