Today I learned that you can use Makefiles to create simple task-runners.
Stuart Feldman invented Make in 1976 to automate build processes for C programs. But you can use it for other languages, too.
For example, Vladislav Supalov uses this Makefile
for Docker commands:
all:
@echo "Usage: build or run"
build:
docker build -t test .
run:
docker run --rm -it test
Now run the file with your terminal:
make
> Usage: build or run
Build the Docker container via make build
or run the container via make run
.
Pitfall: Tabs vs Spaces
My editor replaces tabs with spaces.
Makefiles need tabs, otherwise you’ll get an error:
Makefile:5: *** missing separator. Stop.
If you use Vim, you can setlocal noexpandtab
to revert spaces to tabs.