4 ms·
I like to use makefiles for managing docker containers / images. For my needs it's a more practical and flexible solution than other docker orchestration / mana
by jsz0 10y ago
I like to use makefiles for managing docker containers / images. For my needs it's a more practical and flexible solution than other docker orchestration / management tools I've tried. A few things I've learned that might be useful:
* (cd /path/to/something && make goal)
* You can use .DEFAULT_GOAL := goal_name to set the default target run by 'make' with no target name specified.
* Adding .SILENT will suppress make entering/leaving directory messages. Probably wise to be careful with one until you're 100% sure you're not ending up in an unintended directory doing nasty things.
* You can use $(COLOR) = `tput setaf x' and $(RESET) = `tput sgr0` to add colors to your make output. For example @echo "$(RED)ERROR!$(RESET)"
* Use if ! -f conditionals to start goals that rely on external scripts/programs. Otherwise make will run until it hits the error which will leave you with a partially completed goal.
goal:
@if [ ! -f ./scripts/blah.sh ]; then echo "ERROR: ./scripts/blah.sh not found"; exit 1; fi
@echo "without the if ! -f this command would run"
@echo "and so would this one"
@./scripts/blah.sh $(IMPORTANT_STUFFS)
@echo "but not this one"
- mdaniel 10y ago> You can use .DEFAULT_GOAL := goal_name to set the default target run by 'make' with no target name specified. I had always, perhaps erroneously, thought that the very first goal in the file was the default one.
- moosingin3space 10y agoThis is true -- the first goal declared is the default.
- jsz0 10y agoIIRC .DEFAULT_GOAL is a relatively new feature. If it's not set goals will be processed in the normal order.