Skip to content

Instantly share code, notes, and snippets.

@aussielunix
Created August 8, 2021 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aussielunix/ddc1684d8fb97bc02a2ad6ec77965d2f to your computer and use it in GitHub Desktop.
Save aussielunix/ddc1684d8fb97bc02a2ad6ec77965d2f to your computer and use it in GitHub Desktop.
A Makefile example with a help system
# 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