-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
111 lines (89 loc) · 3.35 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
include docker/mk/*.mk
# Define variables, export them and include them usage-documentation
$(eval $(call defw,NS,25thfloor))
$(eval $(call defw,REPO,ttrack-client))
$(eval $(call defw,VERSION,latest))
$(eval $(call defw,NAME,ttrack))
$(eval $(call defw,GIT_COMMIT,null))
$(eval $(call defw_h,UNAME_S,$(shell uname -s)))
ifeq (Linux,$(UNAME_S))
$(eval $(call defw_h,AS_USER,$(shell id -u -n)))
$(eval $(call defw_h,AS_UID,$(shell id -u)))
$(eval $(call defw_h,AS_GID,$(shell id -g)))
endif
# Deps
running_container := $(shell docker ps -a -f "name=ttrack" --format="{{.ID}}")
# -----------------------------------------------------------------------------
# Build and ship
# -----------------------------------------------------------------------------
.PHONY: build
build:: ##@Docker Build an image
build:: buildinfo
yarn build
$(shell_env) docker build -t $(NS)/$(REPO):$(VERSION) .
.PHONY: ship
ship:: ##@Docker Ship the image (build, ship)
ship:: ship-latest
docker push $(NS)/$(REPO):$(VERSION)
.PHONY: ship-latest
ship-latest:: ##@Docker also ship the image with tagged version latest
docker tag $(NS)/$(REPO):$(VERSION) $(NS)/$(REPO):latest
docker push $(NS)/$(REPO):latest
# -----------------------------------------------------------------------------
# All things deployment - beware
# -----------------------------------------------------------------------------
.PHONY: assets
assets:: ##@Helpers Run tests within the client container
docker exec ttrack-client yarn build
.PHONY: test
test:: ##@Helpers Run tests within the client container
docker exec -e NODE_ENV=test ttrack-client yarn test
# -----------------------------------------------------------------------------
# All the convenient things for developers
# -----------------------------------------------------------------------------
ifeq (yarn,$(firstword $(MAKECMDGOALS)))
YARN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(YARN_ARGS):;@:)
endif
.PHONY: yarn
yarn:: ##@Helpers Run "yarn [<COMMAND>]" within the client container
docker exec -ti ttrack-client yarn $(YARN_ARGS) ${OPTIONS}
.PHONY: shell
shell: ##@Helpers Get a shell within the client container
docker exec -ti ttrack-client bash
.PHONY: buildinfo
buildinfo:: ##@Helpers create the buildinfo json config
$(shell_env) echo 'REACT_APP_VERSION=$(VERSION)\nREACT_APP_GIT=$(GIT_COMMIT)\n' > ./.env
# -----------------------------------------------------------------------------
# Local development & docker-compose
# -----------------------------------------------------------------------------
.PHONY: up
up:: ##@Compose Start the client development stack
$(shell_env) docker-compose \
-f docker-compose.dev.yml \
up \
--build
.PHONY: start
start:: ##@Compose Start the client development stack in detached mode
$(shell_env) docker-compose \
-f docker-compose.dev.yml \
up \
--build \
-d
.PHONY: stop
stop:: ##@Compose Start the client development stack in detached mode
$(shell_env) docker-compose \
-f docker-compose.dev.yml \
stop
.PHONY: rm
rm:: ##@Compose Clean docker-compose stack
docker-compose \
-f docker-compose.dev.yml \
rm \
--force
ifneq ($(running_container),)
@-docker rm -f $(running_container)
endif
# -----------------------------------------------------------------------------
# Travis
# -----------------------------------------------------------------------------