#!/usr/bin/env bash

set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OVERRIDE_FILE="${ROOT_DIR}/compose.traefik.yml"

if [[ ! -f "${OVERRIDE_FILE}" ]]; then
  cat <<'EOF'
Missing compose.traefik.yml.

Copy compose.traefik.yml.sample to compose.traefik.yml, adjust the host and
network settings for production, then rerun this script.
EOF
  exit 1
fi

cd "${ROOT_DIR}"
docker compose -f docker-compose.yml -f compose.traefik.yml up --build -d db backend frontend "$@"

echo "Started the compose stack in detached mode."
echo "Use docker compose logs db backend frontend to inspect service output."
