forked from ustwo/ustwo.com-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (116 loc) · 3.84 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
BASE_PATH ?= $(PWD)
VERSION ?= dev
IDENTITY_FILE ?= ~/.docker/machine/machines/ustwosite/id_rsa
SOURCE_BRANCH ?= master
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
project_name := usweb
project_namespace := ustwo/$(project_name)
internal_path := /home/ustwo
## CLI aliases ################################################################
AWK := awk
CP := cp
GIT := git
GREP := grep
CURL := curl
MKDIR := mkdir -p
FSWATCH := fswatch
RM := rm -rf
MV := mv
XARGS := xargs
DOCKER := docker
DOCKER_CP := $(DOCKER) cp
DOCKER_EXEC := $(DOCKER) exec -it
DOCKER_RM := $(DOCKER) rm -vf
DOCKER_PROC := $(DOCKER) run -d
DOCKER_VOLUME := $(DOCKER) create
DOCKER_TASK := $(DOCKER) run --rm -it
# CircleCI fails if you try to remove a container
DOCKER_CI_TASK := $(DOCKER) run -it
ANSIBLE := $(DOCKER_TASK) \
-v $(IDENTITY_FILE):/root/.ssh/id_rsa \
-v $(PWD):$(internal_path) \
-w $(internal_path) \
ustwo/ansible:1.9.4
ANSIBLE_PLAY := $(ANSIBLE) ansible-playbook -b -v \
--private-key=/root/.ssh/id_rsa \
--inventory-file=$(internal_path)/etc/ansible/hosts
###############################################################################
default: build-all
include tasks/*.mk
## Automatic variables ########################################################
#
# $@ The filename representing the target.
# $% The filename element of an archive member specification.
# $< The filename of the first prerequisite.
# $? The names of all prerequisites that are newer than the target, separated
# by spaces.
# $^ The filenames of all the prerequisites, separated by spaces.
# $+ Similar to $^, this is the names of all the prerequisites separated by
# spaces, except that $+ includes duplicates.
# $* The stem of the target filename. A stem is typically a filename without
# its suffix.
#
###############################################################################
## Porcelain ##################################################################
install: network-create vault-create assets-create app-create sandbox-create diversity-create proxy-create
build-all: compiler-build sandbox-build build
vault: vault-save
build: app-build assets-build sandbox-build
test: assets-unit-test
push: app-push assets-push sandbox-push
pull: app-pull assets-pull sandbox-pull diversity-pull
clean-no-confirm:
@$(DOCKER_RM) $(shell $(DOCKER) ps -aq $(project_filters))
@$(MAKE) network-rm
clean:
$(call confirm,"Are you sure you want to clean __$(DOCKER_MACHINE_NAME)__?",$(MAKE) -i clean-no-confirm)
deploy: clean-no-confirm install
deploy-production:
$(MAKE) -i deploy \
PROXY_HTTPS_PORT=443 \
PROXY_HTTP_PORT=80
deploy-staging: deploy-production
release: release-create
seeds: build
love: deploy
stuff: assets-compile
css: assets-css
css-watch: assets-css-watch
vendors: assets-vendors
spa: assets-spa
images: assets-images
sandbox: sandbox-rm sandbox-create
## Deprecated ################################################################
init: install
## Environment ###############################################################
##
# Lists all containers related to the project.
ps:
@$(DOCKER) ps -a $(project_filters)
##
# Lists the status of all containers related to the project.
stats: quiet_ps := $(shell $(DOCKER) ps -aq $(project_filters))
stats:
@$(if $(quiet_ps), \
$(DOCKER) stats --no-stream $(quiet_ps), \
echo "No containers for $(project_name)")
##
# Lists all images related to the project.
ls:
@$(DOCKER) images \
| $(GREP) $(project_name)
##
# Removes the images for a given version
nuke:
$(DOCKER) images \
| $(GREP) $(project_name) \
| $(GREP) $(VERSION) \
| $(AWK) '{print $$3}' \
| $(XARGS) $(DOCKER) rmi
##
# Absorbs changes from a branch (by default: master) and rebases current branch on top of it.
absorb:
$(GIT) checkout $(SOURCE_BRANCH)
$(GIT) pull --rebase=preserve origin $(SOURCE_BRANCH)
$(GIT) checkout $(GIT_BRANCH)
$(GIT) rebase $(SOURCE_BRANCH)