-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (95 loc) · 3.14 KB
/
Makefile
File metadata and controls
118 lines (95 loc) · 3.14 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
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
#----------------------
# Parse makefile arguments
#----------------------
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(RUN_ARGS):;@:)
#----------------------
# Silence GNU Make
#----------------------
ifndef VERBOSE
MAKEFLAGS += --no-print-directory
endif
#----------------------
# Load .env file
#----------------------
ifneq ("$(wildcard .env)","")
include .env
export
else
endif
DRUNPREFIX=
ifeq ($(OS),Windows_NT)
DRUNPREFIX = winpty
endif
COMPOSE_COMMAND=docker-compose
ifeq ($(APP_ENV),production)
COMPOSE_COMMAND=docker-compose -f docker-compose.yml -f docker-compose.prod.yml
endif
#----------------------
# Terminal
#----------------------
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
#------------------------------------------------------------------
# - Add the following 'help' target to your Makefile
# - Add help text after each target name starting with '\#\#'
# - A category can be added with @category
#------------------------------------------------------------------
.PHONY: build test
HELP_FUN = \
%help; \
while(<>) { \
push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "\n"; \
for (sort keys %help) { \
print "${WHITE}$$_${RESET \
}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print ""; \
}
help: ##@other Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
#----------------------
# docs
#----------------------
docs-generate: ##@docs Generate docs pages and example manifest
@cd backend && go run . docs:generate
docs-build: ##@docs Build VitePress docs
@cd docs && npm run build
docs-embed: ##@docs Copy built docs into backend embed folder
@rm -rf backend/frontend/dist
@mkdir -p backend/frontend/dist
@cp -R docs/.vitepress/dist/. backend/frontend/dist/
docs-package: ##@docs Generate + build docs and stage for backend
@$(MAKE) docs-generate
@$(MAKE) docs-build
@$(MAKE) docs-embed
#----------------------
# docker
#----------------------
DOCKER_PROD_IMAGE ?= docs-web:latest
DOCKER_PROD_PUSH ?= 0
docker-production: ##@docker Build production web image (set DOCKER_PROD_IMAGE / DOCKER_PROD_PUSH=1)
@docker buildx build \
-f containers/web/Dockerfile \
--build-arg GA_MEASUREMENT_ID=$(GA_MEASUREMENT_ID) \
-t $(DOCKER_PROD_IMAGE) \
$(if $(filter 1 true yes,$(DOCKER_PROD_PUSH)),--push,--load) \
.
docker-build-prod: docker-generate-docs-prod docker-production ##@docker Generate docs and build production image
docker-generate-docs-prod: ##@docker Generate docs from upstream repos in a one-off container (updates docs/libraries/*.md)
@$(COMPOSE_COMMAND) run --rm --build docs-generate
docker-deploy-prod: ##@docker Generate docs, build prod image, and roll web container
@$(MAKE) docker-build-prod
@$(COMPOSE_COMMAND) up -d --force-recreate web
#----------------------
# build
#----------------------
build: ##@build Build backend binary
@mkdir -p bin
@cd backend && go build -o ../bin/docs .