Skip to content

Commit

Permalink
Load env changes with single make command (Islandora-Devops#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonRichards authored May 4, 2022
1 parent c7e00e3 commit be7e0db
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ up:

.PHONY: down
.SILENT: down
## Brings down the containers. Same as docker-compose down --remove-orphans
down:
-docker-compose down --remove-orphans

Expand All @@ -434,16 +435,35 @@ login:
docker-compose exec -T drupal with-contenv bash -lc "drush uli --uri=$(DOMAIN)"
echo "=============================\n"

.PHONY: env
.SILENT: env
## Pull in changes to the .env file.
env:
if [ -f .env ]; then \
$(MAKE) down ; \
$(MAKE) -B docker-compose.yml ; \
$(MAKE) pull ; \
$(MAKE) up ; \
fi
if [ ! -f .env ]; then \
echo "No .env file found." ; \
fi

.phony: confirm
confirm:
@echo -n "Are you sure you want to continue and drop your data? [y/N] " && read ans && [ $${ans:-N} = y ]

RESET=$(shell tput sgr0)
RED=$(shell tput setaf 9)
BLUE=$(shell tput setaf 6)
TARGET_MAX_CHAR_NUM=20

.PHONY: help
.SILENT: help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ' ${RED}make${RESET} ${BLUE}<target>${RESET}'
@echo ''
@echo 'Targets:'
# @grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/'
Expand All @@ -452,7 +472,7 @@ help:
if (helpMessage) { \
helpCommand = $$1; sub(/:$$/, "", helpCommand); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
printf " ${RED}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${BLUE}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{lastLine = $$0}' $(MAKEFILE_LIST)
Expand Down

0 comments on commit be7e0db

Please sign in to comment.