forked from bram2w/baserow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (101 loc) · 3.5 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
125
126
127
128
129
130
131
132
133
ifeq ($(shell uname -s),Darwin)
REALPATH:=grealpath -em
else
REALPATH:=realpath -em
endif
SHELL=/bin/bash
WORKDIR:=$(shell $(REALPATH) $(shell pwd))
SUBDIRS:=backend web-frontend
DOCKERCLI:=docker
DOCKERC:=$(DOCKERCLI) compose
DOCKER_SPLIT_CONF:=-f docker-compose.yml -f docker-compose.dev.yml
.PHONY: install build .callsubcmd $(SUBDIRS) help package-build test tests\
lint lint-fix docker-lint\
docker-status docker-build docker-start docker-clean docker-stop docker-kill \
deps deps-upgrade \
clean clean-all
help:
@echo "baserow make. available targets:"
@echo "targets that are executed in backend/frontend dirs:"
@echo " make install - install locally with dependencies"
@echo " make package-build - build packages locally"
@echo " make lint - check code style"
@echo " make test - run test suite"
@echo " make clean-all - remove docker images, venv and frontend node_modules dir"
@echo " "
@echo "targets that are executed at top-dir level:"
@echo ""
@echo " make docker-build - build docker images for dev env"
@echo " make docker-start - start local dev env"
@echo " make docker-stop - stop local dev env"
@echo " make docker-status - show current docker containers"
@echo " make docker-clean - remove docker images"
# create .env file with default values if no file exists
.env:
@cat .env.example > .env
@echo "### DEV VARS" >> .env
@cat .env.dev.example >> .env
@sed -i'' -e 's/replace me with your uid/$(shell id -u)/g' .env
@sed -i'' -e 's/replace me with your gid/$(shell id -g)/g' .env
@echo "Created .env file with default values"
@echo "Please review contents of .env"
@echo ""
# execute $(SUBCMD) in subdirs with make
# NOTE: SUBCMD is substituted at rule level while $SDIR is shell variable
.subcmd:
@echo "calling $(SUBCMD) in subdirs"
for SDIR in $(SUBDIRS); do echo "$$SDIR/$(SUBCMD)"; \
cd $(WORKDIR) && cd $$SDIR && $(MAKE) $(SUBCMD) && cd ..; \
done
# NOTE: each target that need to call subdir mae
install: SUBCMD=install deps-install deps-install-dev
install: .subcmd
package-build: SUBCMD=package-build
package-build: .subcmd
lint: SUBCMD=lint
lint: .subcmd docker-lint
lint-fix: SUBCMD=lint-fix
lint-fix: .subcmd
test: SUBCMD=test
test: .subcmd
tests: test
.docker-build: .env
$(DOCKERC) $(DOCKER_CONFIG_FILES) build
.docker-start: .env
$(DOCKERC) $(DOCKER_CONFIG_FILES) up -d
.docker-stop: .env
$(DOCKERC) $(DOCKER_CONFIG_FILES) stop
.docker-kill: .env
$(DOCKERC) $(DOCKER_CONFIG_FILES) kill
.docker-clean: .env
$(DOCKERC) $(DOCKER_CONFIG_FILES) rm -f -v
docker-build: DOCKER_CONFIG_FILES=$(DOCKER_SPLIT_CONF)
docker-build: .docker-build
docker-start: DOCKER_CONFIG_FILES=$(DOCKER_SPLIT_CONF)
docker-start: docker-build .docker-start
docker-stop: DOCKER_CONFIG_FILES=$(DOCKER_SPLIT_CONF)
docker-stop: .docker-stop
docker-kill: DOCKER_CONFIG_FILES=$(DOCKER_SPLIT_CONF)
docker-kill: .docker-kill
docker-clean: DOCKER_CONFIG_FILES=$(DOCKER_SPLIT_CONF)
docker-clean: docker-stop .docker-clean
docker-lint:
$(DOCKERCLI) run --rm -i -v "$(shell pwd)":/opt/hadolint/. -w /opt/hadolint \
hadolint/hadolint:2.9.3-debian \
hadolint -f tty \
--ignore DL3008 \
backend/Dockerfile \
web-frontend/Dockerfile \
heroku.Dockerfile \
e2e-tests/Dockerfile \
deploy/*/Dockerfile
clean: SUBCMD=clean
clean: .subcmd docker-clean
clean-all: SUBCMD=clean-all
clean-all: .subcmd docker-clean
deps: SUBCMD=deps
deps: .subcmd
deps-upgrade: SUBCMD=deps-upgrade
deps-upgrade: .subcmd
docker-status: .env
$(DOCKERC) $(DOCKER_SPLIT_CONF) ps