-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
124 lines (106 loc) · 2.96 KB
/
Makefile
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
GO ?= go
GOFMT ?= $(GO)fmt
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
GOOPTS ?=
GOOS ?= $(shell $(GO) env GOHOSTOS)
GOARCH ?= $(shell $(GO) env GOHOSTARCH)
IMAGE_NAME ?= ghcr.io/pando85/gearr
IMAGE_VERSION ?= latest
PROJECT_VERSION := 0.1.11
.DEFAULT: help
.PHONY: help
help: ## show this help menu.
@echo "Usage: make [TARGET ...]"
@echo ""
@@egrep -h "#[#]" $(MAKEFILE_LIST) | sed -e 's/\\$$//' | awk 'BEGIN {FS = "[:=].*?#[#] "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ""
.PHONY: build-all
build-all: server worker
build-all: ## build all binaries
.PHONY: server
server: build-server
server: ## build server binary
.PHONY: worker
worker: build-worker
worker: ## build worker binary
.PHONY: build-%
build-%:
@echo "Building dist/gearr-$*"
@if [ "$*" = "server" ]; then \
cd server/web/ui && \
npm install && \
npm run build || exit 1; \
cd -; \
fi
@CGO_ENABLED=0 go build -o dist/gearr-$* $*/main.go
.PHONY: images
images: image-server image-worker
images: ## build container images
.PHONY: images
push-images: push-image-server push-image-worker
push-images: ## build and push container images
DOCKER_BUILD_ARG := --cache-to type=inline
DOCKER_BUILD_ARG += --cache-from $(IMAGE_NAME):latest-build
DOCKER_BUILD_ARG += --cache-from $(IMAGE_NAME):latest-base
.PHONY: image-%
.PHONY: push-image-%
image-% push-image-%: build-%
@export DOCKER_BUILD_ARG="$(DOCKER_BUILD_ARG) $(if $(findstring push,$@),--push,--load)"; \
if [ "$*" = "server" ]; then \
docker buildx build \
$${DOCKER_BUILD_ARG} \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-build \
--target build \
-f Dockerfile \
. ; \
docker buildx build \
$${DOCKER_BUILD_ARG} \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-base \
--target base \
-f Dockerfile \
. ; \
else \
docker buildx build \
$${DOCKER_BUILD_ARG} \
--cache-from $(IMAGE_NAME):latest-worker-pgs \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-worker-pgs \
--target worker-pgs \
-f Dockerfile \
. ; \
fi; \
docker buildx build \
$${DOCKER_BUILD_ARG} \
--cache-from $(IMAGE_NAME):latest-$* \
-t $(IMAGE_NAME):$(IMAGE_VERSION)-$* \
-f Dockerfile \
--target $* \
. ;
.PHONY: run-all
run-all: images
run-all: export NOT_RUN_FRONT=true
run-all: ## run all services in local using docker-compose
run-all:
@scripts/run-all.sh
.PHONY: down
down: ## stop all containers from docker-compose
down:
@docker-compose down --volumes
.PHONY: logs
logs: ## show logs
logs:
@docker-compose logs -f
.PHONY: demo-files
demo-files: ## download demo file
demo-files:
@scripts/get-demo-files.sh
.PHONY: test-upload
test-upload: ## upload job to test all process
test-upload: demo-files run-all
@scripts/test-upload.sh
.PHONY: update-changelog
update-changelog: ## automatically update changelog based on commits
git cliff -t v$(PROJECT_VERSION) -u -p CHANGELOG.md
.PHONY: tag
tag: ## create a tag using version from Cargo.toml
git tag -s v$(PROJECT_VERSION) -m "v$(PROJECT_VERSION)" && \
git push origin v$(PROJECT_VERSION)