#!/usr/bin/env bash
set -euo pipefail

# shellcheck source=scripts/prod-common.sh
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/prod-common.sh"

prod_load_env
prod_require_docker

cd "$BACKEND_DIR"
prod_build_web_if_static

cd "$DEPLOY_DIR"

echo "[prod] building images..."
prod_compose build

prod_ensure_deps
prod_run_init_if_needed

prod_start_app_services
prod_wait_api_health
prod_print_stack_summary