#!/usr/bin/env bash show_help() { echo "Build A script to build the web app's docker images. Usage: build.sh [OPTIONS] Options: -r|--render-templates: Run the render_docker_templates script before building the images. -h|--help: Shows this help message. " } cur_dir="$(cd "$( dirname "$0")" && pwd)" docker_compose_file="$cur_dir/docker/docker-compose.yaml" render_template_script="$cur_dir/docker/bin/render_docker_templates.sh" venv_dir="$cur_dir/venv/bin/activate" render_templates=false while [[ "$#" -gt 0 ]]; do case "$1" in -h|--help) show_help exit ;; -r|--render-templates) render_templates=true shift 1 ;; *) echo "Invalid argument given ($1)" exit 1 ;; esac done source "$venv_dir" # if we need to render the docker templates, then we should do that if "$render_templates"; then $render_template_script fi if [[ ! -f "$docker_compose_file" ]]; then echo "The docker-compose file does not exist (expected at $docker_compose_file)." echo "Run with --render-templates to render the docker-compose file." exit 1 fi sudo docker-compose -f "$docker_compose_file" build