-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
71 lines (54 loc) · 1.48 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
define HELPTEXT
make start # start containers
make stop # stop and remove containers
make dump # create dump.sql from db container
make restore # cleanup admin db in db container and apply dump.sql dump to admin db
make build # build containers but don't start
SERVICE=name # build service `name`
make clean # remove containers
ALL=1 # remove images too
make logs # show logs
SERVICE=name # show logs of service `name`
FOLLOW=1 # follow log
make setup # install prerequisites
endef
PROJECT=dashi
COMPOSE=docker-compose -p $(PROJECT)
SERVICES=db app sidecar adminer
start up:
@$(COMPOSE) up -d
stop down: dump
@$(COMPOSE) down --remove-orphans
build:
@$(COMPOSE) build $(SERVICE)
clean:
@$(COMPOSE) rm
ifeq ($(ALL),1)
@docker rmi -f $(addprefix $(PROJECT)_,$(SERVICES))
endif
dump:
@$(COMPOSE) exec db pg_dump -h localhost -Uadmin -d admin --clean > db/dump.sql
restore:
@$(COMPOSE) exec -T db psql -h localhost -Uadmin -d admin < db/dump.sql
ifeq ($(FOLLOW),1)
LOG_FOLLOW=-f
endif
logs:
@$(COMPOSE) logs $(LOG_FOLLOW) $(SERVICE)
setup:
@./sbin/setup
ifneq ($(HELPTEXT),)
ifneq ($(filter help,$(MAKECMDGOALS)),)
HELPFILE:=$(shell mktemp /tmp/make.help.XXXX)
endif
endif
help:
$(file >$(HELPFILE),$(HELPTEXT))
@echo
@cat $(HELPFILE)
@echo
@-rm -f $(HELPFILE)
.PHONY: start up stop down build clean logs test setup help
.EXPORT_ALL_VARIABLES:
CIRCLE_CI_TOKEN=${CIRCLE_CI_TOKEN}
GH_TOKEN=${GH_TOKEN}