-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (92 loc) · 3.22 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
#!make
SHELL = /bin/sh
.DEFAULT: help
-include .env .env.local .env.*.local
# Defaults
BUILD_VERSION ?= SNAPSHOT
IMAGE_NAME := ${DOCKER_REPO}/${SERVICE_NAME}:${BUILD_VERSION}
IMAGE_NAME_LATEST := ${DOCKER_REPO}/${SERVICE_NAME}:latest
DOCKER_COMPOSE = USERID=$(shell id -u):$(shell id -g) docker-compose ${compose-files}
ALL_ENVS := local ci
env ?= local
suse-instances ?= 1
docker-snapshot ?= true
ifndef SERVICE_NAME
$(error SERVICE_NAME is not set)
endif
ifeq (${env}, ci)
compose-files=-f docker-compose.yml -f docker-compose.ci.yml
endif
.PHONY: help
help:
@echo "Anfield build pipeline"
@echo ""
@echo "Usage:"
@echo " build - Build artifact"
@echo " test.unit - Run unit tests"
@echo " test.integration - Run integration tests"
@echo " test.api - Run api tests"
@echo " test.resiliency - Run resiliency tests"
@echo " docker.publish - Publish docker image (used for internal/external testing purposes) to artifactory. Receives parameter docker-snapshot (default true)"
@echo " docker.wait - Waits until all docker containers have exited successfully and/or are healthy. Timeout: 180 seconds"
@echo " docker.logs - Generate one log file per each service running in docker-compose"
@echo " git.tag - Creates a new tag and pushes it to the git repository. Used to tag the current commit as a released artifact"
@echo ""
@echo " ** The following tasks receive an env parameter to determine the environment they are being executed in. Default env=${env}, possible env values: ${ALL_ENVS}:"
@echo " docker.run.dependencies - Run only SUSE dependencies with docker-compose (default env=${env})". Note that `build` might need to be executed prior.
@echo " docker.stop - Stop and remove all running containers from this project using docker-compose down (default env=${env})"
@echo ""
@echo "Project-level environment variables are set in .env file:"
@echo " SERVICE_NAME=anfield"
@echo " DOCKER_PROJECT_NAME=anfield"
@echo " COMPOSE_PROJECT_NAME=anfield"
@echo " DOCKER_REPO="
@echo " COMPOSE_HTTP_TIMEOUT=360"
@echo ""
@echo "Note: Store protected environment variables in .env.local or .env.*.local"
@echo ""
.PHONY: build
#TODO
.PHONY: docker.build
#TODO
b.clean: clean
#TODO
.PHONY: test.unit
test.unit:
#TODO
.PHONY: test.integration
test.integration:
#TODO
.PHONY: test.api
test.api:
#TODO
.PHONY: test.resiliency
test.resiliency:
#TODO
.PHONY: dependencies
dependencies: docker.run.dependencies
.PHONY: docker.run.dependencies
docker.run.dependencies: d.compose.down
make d.compose.up
make docker.wait
docker-compose ps
make db.replicas.up
.PHONY: docker.stop
docker.stop: d.compose.down
.PHONY: d.compose.up
d.compose.up:
$(call DOCKER_COMPOSE) up -d --remove-orphans --build
.PHONY: docker.wait
docker.wait:
./bin/docker-wait
.PHONY: d.compose.down
d.compose.down:
$(call DOCKER_COMPOSE) down -v || true
$(call DOCKER_COMPOSE) rm --force || true
docker rm "$(docker ps -a -q)" -f || true
.PHONY: db.replicas.up
db.replicas.up:
docker exec mongo1 /scripts/rs-init.sh
.PHONY: db.bash
db.bash:
docker exec -it mongo1 bash