-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (66 loc) · 2.23 KB
/
Copy pathMakefile
File metadata and controls
86 lines (66 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
GOCMD=go
GOTEST=$(GOCMD) test
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
HASH := $(shell git rev-parse --short HEAD)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
GOOS ?= darwin
GOARCH ?= arm64
PROJECT_NAME := kitchen
LINTER_BIN ?= golangci-lint
include .env
export
.PHONY: all test build clean run lint /bin/$(LINTER_BIN)
all: help
## Build:
build: ## Build all the binaries and put the output in bin/
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOCMD) build -ldflags "-X main.version=$(BRANCH)-$(HASH)" -o bin/$(PROJECT_NAME)
## Build:
build-linux: ## Build all the binaries and put the output in bin/
GOOS=linux GOARCH=amd64 $(GOCMD) build -ldflags "-X main.version=$(BRANCH)-$(HASH)" -o bin/$(PROJECT_NAME)
## Build frontend:
build-frontend: ## Build frontend
cd frontend && pnpm build && cp -R dist ../
build-docker: ## Build Docker image
docker build -t $(PROJECT_NAME) .
build-docker-compose: ## Build all services via docker compose
docker compose up --build -d
bin/$(LINTER_BIN):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v2.11.4
## Clean:
clean: ## Remove build related file
@-rm -fr ./bin/$(PROJECT_NAME)
@-rm -fr ./kitchen.db kitchen.dh-shm kitchen.db-wal
## Lint:
lint: bin/$(LINTER_BIN)
./bin/$(LINTER_BIN) run
## Run:
run: ## Run the `make run`
./bin/$(PROJECT_NAME) $(ARGS)
## Run frontend:
run-frontend: ## Run
cd frontend && pnpm dev
## Run backend:
run-backend: ## Run
$(GOCMD) run $(PROJECT_NAME).go
config-docker: ## Generate kitchen config
docker run -it $(PROJECT_NAME) config > config.yaml
config: ## Generate default config
./bin/$(PROJECT_NAME) config > ./config.yaml
## Test:
test: ## Run the tests of the smolgit
$(GOTEST) -race ./...
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)