Created
August 8, 2021 00:38
-
-
Save aussielunix/ddc1684d8fb97bc02a2ad6ec77965d2f to your computer and use it in GitHub Desktop.
A Makefile example with a help system
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
# HELP | |
# This will output the help for each task | |
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | |
.PHONY: help | |
help: ## This help. | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
.DEFAULT_GOAL := help | |
ENV ?= local | |
start: ## Run in local development mode | |
@echo "Starting development server..." | |
@docker-compose build dev | |
@docker-compose up -d dev | |
@docker-compose exec dev npm install | |
@echo "run 'make stop' to shutdown your dev environment" | |
log: ## Stream the logs from the running container | |
@echo "Streaming logs from the running dev container" | |
@docker-compose logs -f dev | |
shell: ## get a shell on your running dev environment | |
@echo "This will give you a local shell in your dev environment" | |
@docker-compose exec dev bash | |
test: ## Run unit testing | |
@echo "This is the unit tests you should have..." | |
@echo "please implement me" | |
@docker-compose exec dev npm run test | |
stop: ## Stop a running dev environment | |
@echo "Stopping your development environment" | |
@docker-compose down --remove-orphans | |
prod: ## Run production build | |
@echo "Running production build..." | |
@docker-compose exec dev npm run build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment