Skip to content

Commit 25e6ac6

Browse files
authored
feat: add make help (#1357)
Based on https://gist.github.com/prwhite/8168133
1 parent 500874b commit 25e6ac6

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

Makefile

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,55 @@ PORT ?= 4000
44

55
.PHONY: dev dev.orange seed prod bench.% dev_db start start.% stop stop.% rebuild rebuild.%
66

7-
dev:
7+
.DEFAULT_GOAL := help
8+
9+
# Common commands
10+
11+
dev: ## Start a dev server
812
ELIXIR_ERL_OPTIONS="+hmax 1000000000" SLOT_NAME_SUFFIX=some_sha PORT=$(PORT) MIX_ENV=dev SECURE_CHANNELS=true API_JWT_SECRET=dev METRICS_JWT_SECRET=dev REGION=fra FLY_ALLOC_ID=123e4567-e89b-12d3-a456-426614174000 DB_ENC_KEY="1234567890123456" CLUSTER_STRATEGIES=$(CLUSTER_STRATEGIES) ERL_AFLAGS="-kernel shell_history enabled" iex --name $(NODE_NAME)@127.0.0.1 --cookie cookie -S mix phx.server
913

10-
dev.orange:
14+
dev.orange: ## Start another dev server (orange) on port 4001
1115
ELIXIR_ERL_OPTIONS="+hmax 1000000000" SLOT_NAME_SUFFIX=some_sha PORT=4001 MIX_ENV=dev SECURE_CHANNELS=true API_JWT_SECRET=dev METRICS_JWT_SECRET=dev FLY_REGION=fra FLY_ALLOC_ID=123e4567-e89b-12d3-a456-426614174000 DB_ENC_KEY="1234567890123456" CLUSTER_STRATEGIES=$(CLUSTER_STRATEGIES) ERL_AFLAGS="-kernel shell_history enabled" iex --name [email protected] --cookie cookie -S mix phx.server
1216

13-
seed:
17+
seed: ## Seed the database
1418
DB_ENC_KEY="1234567890123456" FLY_ALLOC_ID=123e4567-e89b-12d3-a456-426614174000 mix run priv/repo/seeds.exs
1519

16-
prod:
20+
prod: ## Start a server with a MIX_ENV=prod
1721
ELIXIR_ERL_OPTIONS="+hmax 1000000000" SLOT_NAME_SUFFIX=some_sha MIX_ENV=prod FLY_APP_NAME=realtime-local API_KEY=dev SECURE_CHANNELS=true API_JWT_SECRET=dev METRICS_JWT_SECRET=dev FLY_REGION=fra FLY_ALLOC_ID=123e4567-e89b-12d3-a456-426614174000 DB_ENC_KEY="1234567890123456" SECRET_KEY_BASE=M+55t7f6L9VWyhH03R5N7cIhrdRlZaMDfTE6Udz0eZS7gCbnoLQ8PImxwhEyao6D DASHBOARD_USER=realtime_local DASHBOARD_PASSWORD=password ERL_AFLAGS="-kernel shell_history enabled" iex -S mix phx.server
1822

19-
bench.%:
23+
bench.%: ## Run benchmark with a specific file. e.g. bench.secrets
2024
ELIXIR_ERL_OPTIONS="+hmax 1000000000" SLOT_NAME_SUFFIX=some_sha MIX_ENV=dev SECURE_CHANNELS=true API_JWT_SECRET=dev METRICS_JWT_SECRET=dev FLY_REGION=fra FLY_ALLOC_ID=123e4567-e89b-12d3-a456-426614174000 DB_ENC_KEY="1234567890123456" ERL_AFLAGS="-kernel shell_history enabled" mix run bench/$*
2125

22-
dev_db:
26+
dev_db: ## Start dev databases using docker
2327
docker-compose -f docker-compose.dbs.yml up -d && mix ecto.migrate --log-migrator-sql
24-
#########################
25-
# Docker
26-
#########################
2728

28-
start:
29+
# Docker specific commands
30+
31+
start: ## Start main docker compose
2932
docker-compose up
3033

31-
start.%:
34+
start.%: ## Start docker compose with a specific file. e.g. start.dbs
3235
docker-compose -f docker-compose.$*.yml up
3336

34-
stop:
37+
stop: ## Stop main docker compose
3538
docker-compose down --remove-orphans
3639

37-
stop.%:
40+
stop.%: ## Stop docker compose with a specific file. e.g. stop.dbs
3841
docker-compose -f docker-compose.yml -f docker-compose.$*.yml down --remove-orphans
3942

40-
rebuild:
43+
rebuild: ## Rebuild main docker compose images
4144
make stop
4245
docker-compose build
4346
docker-compose up --force-recreate --build
4447

45-
rebuild.%:
48+
rebuild.%: ## Rebuild docker compose images with a specific file. e.g. rebuild.dbs
4649
make stop.$*
4750
docker-compose -f docker-compose.yml -f docker-compose.$*.yml build
4851
docker-compose -f docker-compose.yml -f docker-compose.$*.yml up --force-recreate --build
52+
53+
# Based on https://gist.github.com/prwhite/8168133
54+
.DEFAULT_GOAL:=help
55+
.PHONY: help
56+
help: ## Display this help
57+
$(info Realtime commands)
58+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[%.a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)