Last active
September 6, 2022 20:39
-
-
Save Pierstoval/6e95531e56ba26e88307d19f76603d87 to your computer and use it in GitHub Desktop.
Reset your entire application securely from a Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# When you run "make full-reset", you see a warning message telling you to | |
# re-run the command with an environment variable if you're sure. | |
# | |
# So to *actually* execute the command, you have to run "make -e RESET=1 full-reset". | |
# Feel free to change the "resetting" scripts as you want. | |
# | |
# These are helper vars to use to have a nicer display for messages | |
_TITLE := "\033[32m[%s]\033[0m %s\n" # Green text | |
_ERROR := "\033[31m[%s]\033[0m %s\n" # Red text | |
full-reset: | |
@printf $(_ERROR) "WARNING" "This will remove ALL containers, data, cache, to make a fresh project! Use at your own risk!" | |
@if [[ -z "$(RESET)" ]]; then \ | |
printf $(_ERROR) "WARNING" "If you are 100% sure of what you are doing, re-run with $(MAKE) -e RESET=1 full-reset" ; \ | |
exit 0 ; \ | |
fi ; \ | |
\ | |
\ | |
`# Resetting scripts:` \ | |
\ | |
$(DOCKER_COMPOSE) down --volumes --remove-orphans && \ | |
rm -rf \ | |
"var/cache/*" \ | |
"var/uploads/*" \ | |
"var/log/*" \ | |
"var/sessions/*" \ | |
public/build \ | |
public/bundles \ | |
public/uploads \ | |
node_modules \ | |
vendor \ | |
&& \ | |
\ | |
`# End of resetting scripts` \ | |
\ | |
printf $(_TITLE) "OK" "Done!" | |
.PHONY: full-reset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment