Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (46 loc) · 1.38 KB
/
Copy pathMakefile
File metadata and controls
59 lines (46 loc) · 1.38 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
APP_NAME := taskforge
IMAGE_NAME := taskforge-api:local
COMPOSE := docker compose
GO_PACKAGES := ./...
GOCACHE ?= $(CURDIR)/.cache/go-build
GOMODCACHE ?= $(CURDIR)/.cache/go-mod
GOENV := GOCACHE=$(GOCACHE) GOMODCACHE=$(GOMODCACHE)
.PHONY: help build run test tidy docker-build up down restart logs ps clean
help:
@printf "Targets:\n"
@printf " build Build the API binary into ./bin/%s\n" "$(APP_NAME)"
@printf " run Run the API locally\n"
@printf " test Run Go tests\n"
@printf " tidy Tidy Go modules\n"
@printf " docker-build Build the Docker image\n"
@printf " up Start the Docker Compose stack\n"
@printf " down Stop the Docker Compose stack\n"
@printf " restart Restart the Docker Compose stack\n"
@printf " logs Tail Docker Compose logs\n"
@printf " ps Show Docker Compose services\n"
@printf " clean Remove local build output\n"
build:
@mkdir -p bin
$(GOENV) go build -trimpath -o bin/$(APP_NAME) ./cmd/taskforge
run:
$(GOENV) go run ./cmd/taskforge
test:
$(GOENV) go test $(GO_PACKAGES)
tidy:
$(GOENV) go mod tidy
docker-build:
$(COMPOSE) build api
up:
$(COMPOSE) up --build -d
down:
$(COMPOSE) down
restart:
$(COMPOSE) down
$(COMPOSE) up --build -d
logs:
$(COMPOSE) logs -f
ps:
$(COMPOSE) ps
clean:
@if [ -d .cache ]; then chmod -R u+w .cache; fi
rm -rf bin .cache