|
1 | 1 | GO_SOURCES=$(shell find . -type f -name '*.go' -not -path "./vendor/*") |
2 | 2 | FRONTEND_BUILD_DIR = pkg/web/build |
3 | 3 |
|
4 | | -# Builds frontend and backend Go code. |
5 | | -build: |
| 4 | +.PHONY: build |
| 5 | +build: build-web build-go # Builds frontend and backend |
| 6 | + |
| 7 | +.PHONY: build-web |
| 8 | +build-web: # Build frontend assets |
6 | 9 | rm -rf $(FRONTEND_BUILD_DIR) |
7 | 10 | export PUBLIC_BACKEND_ENDPOINT="" && \ |
8 | 11 | export PUBLIC_BACKEND_WS_ENDPOINT="" && \ |
9 | 12 | cd pkg/web && npm install && npm run build |
10 | | - make build-go |
11 | 13 |
|
12 | | -# Does not (re)build frontend files, only Go code. |
13 | | -build-go: |
| 14 | +.PHONY: build-go |
| 15 | +build-go: # Build Go binary (doesn't rebuild frontend) |
14 | 16 | mkdir -p $(FRONTEND_BUILD_DIR) |
15 | 17 | test -e $(FRONTEND_BUILD_DIR)/index.html || \ |
16 | 18 | cp pkg/web/dev.html $(FRONTEND_BUILD_DIR)/index.html |
17 | 19 | go build -o bin/quickpizza ./cmd |
18 | 20 |
|
19 | 21 | .PHONY: proto |
20 | | -proto: |
| 22 | +proto: # Generate protobuf files |
21 | 23 | protoc --go_out=. --go-grpc_out=. proto/quickpizza.proto |
22 | 24 |
|
23 | | -format: |
| 25 | +.PHONY: format |
| 26 | +format: format-go format-web |
| 27 | + |
| 28 | +.PHONY: format-go |
| 29 | +format-go: # Format Go code with goimports |
24 | 30 | @goimports -w -l $(GO_SOURCES) |
25 | 31 |
|
26 | | -format-web: |
| 32 | +.PHONY: format-web |
| 33 | +format-web: # Format frontend code |
27 | 34 | cd pkg/web/ && npm run format |
28 | 35 |
|
29 | | -format-check: |
| 36 | +.PHONY: format-check |
| 37 | +format-check: # Check Go code formatting |
30 | 38 | @out=$$(goimports -l $(GO_SOURCES)) && echo "$$out" && test -z "$$out" |
31 | 39 |
|
32 | | -docker-build: |
| 40 | +.PHONY: docker-build |
| 41 | +docker-build: # Build Docker image |
33 | 42 | docker build . -t grafana/quickpizza-local:latest |
34 | 43 |
|
35 | | -docker-run: |
| 44 | +.PHONY: docker-run |
| 45 | +docker-run: # Run Docker container |
36 | 46 | docker run --rm -it -p 3333:3333 -p 3334:3334 -p 3335:3335 -v $$(pwd):/db -e QUICKPIZZA_DB=file:/db/quickpizza.db grafana/quickpizza-local:latest |
| 47 | + |
| 48 | +.PHONY: help |
| 49 | +help: # Show help for each of the Makefile recipes. |
| 50 | + @grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done |
| 51 | + |
0 commit comments