diff --git a/commands/env.cmd b/commands/env.cmd index 7f464e1a..64336816 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -19,6 +19,9 @@ trap '' ERR ## define source repository if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")" + + ## configure mutagen enable by default + WARDEN_MUTAGEN_ENABLE=${WARDEN_MUTAGEN_ENABLE:-1} fi export WARDEN_IMAGE_REPOSITORY="${WARDEN_IMAGE_REPOSITORY:-"docker.io/wardenenv"}" @@ -174,7 +177,10 @@ TRAEFIK_ADDRESS="$(docker container inspect traefik \ )" export TRAEFIK_ADDRESS; -if [[ $OSTYPE =~ ^darwin ]]; then +if [[ $OSTYPE =~ ^darwin ]] && [[ ${WARDEN_MUTAGEN_ENABLE} -eq 1 ]]; then + echo -e "\033[31mWe noticed that you're on MacOS and using Mutagen sync.\033[0m" + echo -e "\033[31mWe recommend configuring Docker Desktop to use VirtioFS and disable Mutagen sync by adding WARDEN_MUTAGEN_ENABLE=0 in ~/.warden/.env file.\033[0m" + export MUTAGEN_SYNC_FILE="${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.mutagen.yml" if [[ -f "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.mutagen.yml" ]]; then diff --git a/commands/install.cmd b/commands/install.cmd index 2034a92e..e5ff0463 100644 --- a/commands/install.cmd +++ b/commands/install.cmd @@ -93,5 +93,7 @@ if [[ ! -f "${WARDEN_HOME_DIR}/.env" ]]; then WARDEN_PORTAINER_ENABLE=0 # SEt to "0" to disable DNSMasq WARDEN_DNSMASQ_ENABLE=1 + # Set to "1" to enable Mutagen + WARDEN_MUTAGEN_ENABLE=1 EOT fi diff --git a/environments/drupal/drupal.darwin.yml b/environments/drupal/drupal.darwin.mutagen.yml similarity index 100% rename from environments/drupal/drupal.darwin.yml rename to environments/drupal/drupal.darwin.mutagen.yml diff --git a/environments/includes/blackfire.darwin.yml b/environments/includes/blackfire.darwin.mutagen.yml similarity index 100% rename from environments/includes/blackfire.darwin.yml rename to environments/includes/blackfire.darwin.mutagen.yml diff --git a/environments/includes/nginx.darwin.yml b/environments/includes/nginx.darwin.mutagen.yml similarity index 100% rename from environments/includes/nginx.darwin.yml rename to environments/includes/nginx.darwin.mutagen.yml diff --git a/environments/includes/php-fpm.darwin.yml b/environments/includes/php-fpm.darwin.mutagen.yml similarity index 100% rename from environments/includes/php-fpm.darwin.yml rename to environments/includes/php-fpm.darwin.mutagen.yml diff --git a/environments/magento1/magento1.blackfire.darwin.yml b/environments/magento1/magento1.blackfire.darwin.mutagen.yml similarity index 100% rename from environments/magento1/magento1.blackfire.darwin.yml rename to environments/magento1/magento1.blackfire.darwin.mutagen.yml diff --git a/environments/magento1/magento1.darwin.yml b/environments/magento1/magento1.darwin.mutagen.yml similarity index 100% rename from environments/magento1/magento1.darwin.yml rename to environments/magento1/magento1.darwin.mutagen.yml diff --git a/environments/magento2/magento2.blackfire.darwin.yml b/environments/magento2/magento2.blackfire.darwin.mutagen.yml similarity index 100% rename from environments/magento2/magento2.blackfire.darwin.yml rename to environments/magento2/magento2.blackfire.darwin.mutagen.yml diff --git a/environments/magento2/magento2.darwin.yml b/environments/magento2/magento2.darwin.mutagen.yml similarity index 100% rename from environments/magento2/magento2.darwin.yml rename to environments/magento2/magento2.darwin.mutagen.yml diff --git a/environments/magento2/magento2.magepack.darwin.yml b/environments/magento2/magento2.magepack.darwin.mutagen.yml similarity index 100% rename from environments/magento2/magento2.magepack.darwin.yml rename to environments/magento2/magento2.magepack.darwin.mutagen.yml diff --git a/environments/shopware/shopware.darwin.yml b/environments/shopware/shopware.darwin.mutagen.yml similarity index 100% rename from environments/shopware/shopware.darwin.yml rename to environments/shopware/shopware.darwin.mutagen.yml diff --git a/utils/env.sh b/utils/env.sh index 598021d6..f41bce50 100644 --- a/utils/env.sh +++ b/utils/env.sh @@ -53,6 +53,10 @@ function loadEnvConfig () { ;; esac + if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then + eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")" + fi + assertValidEnvType } @@ -119,21 +123,27 @@ function appendEnvPartialIfExists () { local PARTIAL_PATH="" for PARTIAL_PATH in \ - "${WARDEN_DIR}/environments/includes/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_DIR}/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_HOME_DIR}/environments/includes/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_HOME_DIR}/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_ENV_PATH}/.warden/environments/includes/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_ENV_PATH}/.warden/environments/includes/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" \ - "${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" + "${WARDEN_DIR}/environments" \ + "${WARDEN_HOME_DIR}/environments" \ + "${WARDEN_ENV_PATH}/.warden/environments"; do - if [[ -f "${PARTIAL_PATH}" ]]; then - DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}") - fi + for PARTIAL_PATH in \ + "${PARTIAL_PATH}/includes/${PARTIAL_NAME}" \ + "${PARTIAL_PATH}/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}"; + do + for PARTIAL_PATH in \ + "${PARTIAL_PATH}.base" \ + "${PARTIAL_PATH}.${WARDEN_ENV_SUBT}"; + do + if [[ -f "${PARTIAL_PATH}.yml" ]]; then + DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}.yml") + fi + if [[ "${WARDEN_ENV_SUBT}" == "darwin" ]] && + [[ "${WARDEN_MUTAGEN_ENABLE}" == "1" ]] && + [[ -f "${PARTIAL_PATH}.mutagen.yml" ]]; then + DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}.mutagen.yml") + fi + done + done done }