forked from TACC/abaco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
151 lines (118 loc) · 4.31 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Makefile for local development
.PHONY: down clean nuke
# Retrieves present working directory (./abaco) and sets abaco tag based on
# current or default values
ifdef abaco_path
export abaco_path := $(abaco_path)
else
export abaco_path := $(PWD)
endif
ifdef TAG
export TAG := $(TAG)
else
export TAG := dev
endif
ifdef in_jenkins
unexport interactive
else
export interactive := -it
endif
ifdef docker_ready_wait
export docker_ready_wait := $(docker_ready_wait)
else
export docker_ready_wait := 15
endif
ifdef maxErrors
export maxErrors := $(maxErrors)
else
export maxErrors := 999
endif
# Gets all remote images and starts Abaco suite in daemon mode
deploy:
@docker rmi abaco/core:$$TAG
@docker pull abaco/core:$$TAG
@docker-compose up -d
# Builds core locally and sets to correct tag. This should take priority over DockerHub images
build-core:
@docker build -t abaco/core:$$TAG ./
# Builds prometheus locally
build-prom:
@docker build -t abaco/prom:$$TAG prometheus/.
# Builds nginx
build-nginx:
@docker build -t abaco/nginx:$$TAG images/nginx/.
# Builds core locally and then runs with Abaco suite with that abaco/core image in daemon mode
local-deploy: build-core build-nginx
sed -i.bak 's/TAG:.*/TAG: '$$TAG'/g' local-dev.conf
@docker-compose --project-name=abaco up -d
# Builds local everything and runs both camel case
# and snake case tests.
# Can run specific test based on the 'test' environment variable
# ex: export test=test/load_tests.py
test:
@echo "\n\nRunning Both Tests.\n"
make test-camel
make down
make test-snake
make down
@echo "Converting back to camel"
sed -i.bak 's/case: camel/case: snake/g' local-dev.conf
# Builds local everything and performs testsuite for camel case.
# Can run specific test based on the 'test' environment variable
# ex: export test=test/load_tests.py
test-camel: build-testsuite
@echo "\n\nCamel Case Tests.\n"
@echo "Converting config file to camel case and launching Abaco Stack.\n"
sed -i.bak 's/TAG:.*/TAG: '$$TAG'/g' local-dev.conf
sed -i.bak 's/case: snake/case: camel/g' local-dev.conf
make local-deploy
sleep $$docker_ready_wait
docker run $$interactive --entrypoint=/tests/entry.sh --network=abaco_abaco -e base_url=http://nginx -e maxErrors=$$maxErrors -e case=camel -v /:/host -v $$abaco_path/local-dev.conf:/etc/service.conf --rm abaco/core:$$TAG $$test
# Builds local everything and performs testsuite for snake case.
# Converts local-dev.conf back to camel case after test.
# Can run specific test based on the 'test' environment variable
# ex: export test=test/load_tests.py
test-snake: build-testsuite
@echo "\n\nSnake Case Tests.\n"
@echo "Converting config file to snake case and launching Abaco Stack.\n"
sed -i.bak 's/TAG:.*/TAG: '$$TAG'/g' local-dev.conf
sed -i.bak 's/case: camel/case: snake/g' local-dev.conf
make local-deploy
sleep $$docker_ready_wait
docker run $$interactive --entrypoint=/tests/entry.sh --network=abaco_abaco -e base_url=http://nginx -e maxErrors=$$maxErrors -e case=snake -v /:/host -v $$abaco_path/local-dev.conf:/etc/service.conf --rm abaco/core:$$TAG $$test
@echo "Converting back to camel"; sed -i.bak 's/case: snake/case: camel/g' local-dev.conf
# Pulls all Docker images not yet available but needed to run Abaco suite
pull:
@docker-compose pull
# Builds testsuite
build-testsuite:
@echo "build-testsuite deprecated; tests now packaged in the abaco/core image."
# Builds a few sample Docker images
samples:
@docker build -t abaco_test -f samples/abaco_test/Dockerfile samples/abaco_test
@docker build -t docker_ps -f samples/docker_ps/Dockerfile samples/docker_ps
@docker build -t word_count -f samples/word_count/Dockerfile samples/word_count
# Creates every Docker image in samples folder
all-samples:
@for file in samples/*; do \
if [[ "$$file" != "samples/README.md" ]]; then \
docker build -t $$file -f $$file/Dockerfile $$file; \
fi \
done
# Test setting of environment variables
vars:
@echo $$TAG
@echo $$abaco_path
@echo $$interactive
# Ends all active Docker containers needed for abaco
down:
@docker-compose down
# Does a clean and also deletes all images needed for abaco
clean:
@docker-compose down --remove-orphans -v --rmi all
# Deletes ALL images, containers, and volumes forcefully
nuke:
@docker rm -f `docker ps -aq`
@docker rmi -f `docker images -aq`
@docker container prune -f
@docker volume prune -f