From 7948a8253e36a743490e19d1258d1c712066c472 Mon Sep 17 00:00:00 2001 From: jose luis munoz Date: Thu, 15 Feb 2024 12:20:37 +0100 Subject: [PATCH 1/3] optional Mutagen in warden env config --- commands/env.cmd | 10 +++++++++- commands/install.cmd | 2 ++ utils/env.sh | 22 ++++++++++++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/commands/env.cmd b/commands/env.cmd index 7f464e1a..85917d2d 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -19,6 +19,11 @@ trap '' ERR ## define source repository if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")" + + ## Temporary fix to force mutagen activation + if [[ ${WARDEN_MUTAGEN_ENABLE} == '' ]]; then + export WARDEN_MUTAGEN_ENABLE=1 + fi fi export WARDEN_IMAGE_REPOSITORY="${WARDEN_IMAGE_REPOSITORY:-"docker.io/wardenenv"}" @@ -174,7 +179,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[31mMutagen is being deprecated!!\033[0m" + echo -e "\033[31mTo disable it, add 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..f2437946 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/utils/env.sh b/utils/env.sh index 598021d6..397574e9 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 } @@ -122,18 +126,28 @@ function appendEnvPartialIfExists () { "${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_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.base.yml" do if [[ -f "${PARTIAL_PATH}" ]]; then DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}") fi done + + if [[ "${WARDEN_ENV_SUBT}" == "darwin" ]] && [[ "${WARDEN_MUTAGEN_ENABLE}" == "1" ]]; then + for PARTIAL_PATH in \ + "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ + "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ + "${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" + do + if [[ -f "${PARTIAL_PATH}" ]]; then + DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}") + fi + done + fi; + } From 3d18dc8c248d98e9e4e7c2c989fb3369915e018c Mon Sep 17 00:00:00 2001 From: jose luis munoz Date: Fri, 16 Feb 2024 14:44:00 +0100 Subject: [PATCH 2/3] added mutagen enable by default --- commands/env.cmd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/commands/env.cmd b/commands/env.cmd index 85917d2d..b0ffadcf 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -20,10 +20,8 @@ trap '' ERR if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(sed 's/\r$//g' < "${WARDEN_HOME_DIR}/.env" | grep "^WARDEN_")" - ## Temporary fix to force mutagen activation - if [[ ${WARDEN_MUTAGEN_ENABLE} == '' ]]; then - export WARDEN_MUTAGEN_ENABLE=1 - fi + ## configure mutagen enable by default + WARDEN_MUTAGEN_ENABLE=${WARDEN_MUTAGEN_ENABLE:-1} fi export WARDEN_IMAGE_REPOSITORY="${WARDEN_IMAGE_REPOSITORY:-"docker.io/wardenenv"}" From c5f87615cc48f515d29f4a9a2b595db75a50b8ab Mon Sep 17 00:00:00 2001 From: jose luis munoz Date: Fri, 1 Mar 2024 14:18:55 +0100 Subject: [PATCH 3/3] refactoring appendEnvPartialIfExists --- commands/env.cmd | 4 +- commands/install.cmd | 4 +- ...l.darwin.yml => drupal.darwin.mutagen.yml} | 0 ...arwin.yml => blackfire.darwin.mutagen.yml} | 0 ...nx.darwin.yml => nginx.darwin.mutagen.yml} | 0 ....darwin.yml => php-fpm.darwin.mutagen.yml} | 0 ... => magento1.blackfire.darwin.mutagen.yml} | 0 ...darwin.yml => magento1.darwin.mutagen.yml} | 0 ... => magento2.blackfire.darwin.mutagen.yml} | 0 ...darwin.yml => magento2.darwin.mutagen.yml} | 0 ...l => magento2.magepack.darwin.mutagen.yml} | 0 ...darwin.yml => shopware.darwin.mutagen.yml} | 0 utils/env.sh | 42 +++++++++---------- 13 files changed, 23 insertions(+), 27 deletions(-) rename environments/drupal/{drupal.darwin.yml => drupal.darwin.mutagen.yml} (100%) rename environments/includes/{blackfire.darwin.yml => blackfire.darwin.mutagen.yml} (100%) rename environments/includes/{nginx.darwin.yml => nginx.darwin.mutagen.yml} (100%) rename environments/includes/{php-fpm.darwin.yml => php-fpm.darwin.mutagen.yml} (100%) rename environments/magento1/{magento1.blackfire.darwin.yml => magento1.blackfire.darwin.mutagen.yml} (100%) rename environments/magento1/{magento1.darwin.yml => magento1.darwin.mutagen.yml} (100%) rename environments/magento2/{magento2.blackfire.darwin.yml => magento2.blackfire.darwin.mutagen.yml} (100%) rename environments/magento2/{magento2.darwin.yml => magento2.darwin.mutagen.yml} (100%) rename environments/magento2/{magento2.magepack.darwin.yml => magento2.magepack.darwin.mutagen.yml} (100%) rename environments/shopware/{shopware.darwin.yml => shopware.darwin.mutagen.yml} (100%) diff --git a/commands/env.cmd b/commands/env.cmd index b0ffadcf..64336816 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -178,8 +178,8 @@ TRAEFIK_ADDRESS="$(docker container inspect traefik \ export TRAEFIK_ADDRESS; if [[ $OSTYPE =~ ^darwin ]] && [[ ${WARDEN_MUTAGEN_ENABLE} -eq 1 ]]; then - echo -e "\033[31mMutagen is being deprecated!!\033[0m" - echo -e "\033[31mTo disable it, add WARDEN_MUTAGEN_ENABLE=0 in ~/.warden/.env file\033[0m" + 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" diff --git a/commands/install.cmd b/commands/install.cmd index f2437946..e5ff0463 100644 --- a/commands/install.cmd +++ b/commands/install.cmd @@ -93,7 +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 + # 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 397574e9..f41bce50 100644 --- a/utils/env.sh +++ b/utils/env.sh @@ -123,31 +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_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_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_DIR}/environments" \ + "${WARDEN_HOME_DIR}/environments" \ + "${WARDEN_ENV_PATH}/.warden/environments"; do - if [[ -f "${PARTIAL_PATH}" ]]; then - DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}") - fi - done - - if [[ "${WARDEN_ENV_SUBT}" == "darwin" ]] && [[ "${WARDEN_MUTAGEN_ENABLE}" == "1" ]]; then for PARTIAL_PATH in \ - "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_HOME_DIR}/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" \ - "${WARDEN_ENV_PATH}/.warden/environments/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}.${WARDEN_ENV_SUBT}.yml" + "${PARTIAL_PATH}/includes/${PARTIAL_NAME}" \ + "${PARTIAL_PATH}/${WARDEN_ENV_TYPE}/${PARTIAL_NAME}"; do - if [[ -f "${PARTIAL_PATH}" ]]; then - DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}") - fi + 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 - fi; - + done }