#!/usr/bin/env bash set -euf -o pipefail # Check if yq is installed if ! command -v yq &>/dev/null; then echo "yq is required but not installed. Please install it manually." exit 1 fi STAGE="${1:-}" shift || true if [[ -z "${STAGE,,}" ]]; then echo "Usage: $0 " echo "Example: $0 test" exit 1 fi if [[ "${STAGE,,}" == "prod" ]]; then DOCKER_COMPOSE_CLI="docker compose" elif [[ "${STAGE,,}" == "test" ]]; then DOCKER_COMPOSE_CLI="docker-compose-2.32.4" else echo "Invalid stage: ${STAGE,,}. Use 'prod' or 'test'." exit 1 fi cd "$(dirname "$(realpath "$0")")/../" AUTHENTIK_DOCKER_COMPOSE_PATH="$(realpath "$(pwd)")" # Merge docker-compose files using yq # 1st merger is docker-compose.override.yml on top of the base docker-compose.yml # 2nd merger is the stage-specific docker-compose file on top of the result of the first merger # The final result is piped to docker compose command yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' \ docker-compose.yml \ docker-compose.override.yml \ | yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' \ - \ docker-compose.${STAGE,,}.yml \ | ${DOCKER_COMPOSE_CLI} -f- ${@:-}