forked from okchaty/ansible-role-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.mk
72 lines (63 loc) · 2.39 KB
/
docker.mk
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
# Docker
.PHONY: docker.help docker.build docker.test docker.pkg
PATH_DOCKER_COMPOSE:=provision/docker-compose
DOCKER_NETWORK = $(PROJECT)_network
docker.help:
@echo ' Docker:'
@echo ''
@echo ' docker.build build all services with docker-compose'
@echo ' docker.down down services docker-compose'
@echo ' docker.ssh connect by ssh to container'
@echo ' docker.stop stop services by env'
@echo ' docker.verify_network verify network'
@echo ' docker.up up services of docker-compose'
@echo ' docker.run run {service} {env}'
@echo ' docker.list list services of docker'
@echo ''
docker.run: clean
@if [ "${env}" == "" ]; then \
docker-compose run --rm --service-ports "${service}" bash; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml run --rm --service-ports "${service}" bash; \
fi
docker.build: clean
@echo $(MESSAGE) "Building environment: ${env}"
@if [ "${env}" == "" ]; then \
docker-compose build; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml build; \
fi
docker.down: clean
@echo $(MESSAGE) "Down Services Environment: ${env}"
@if [ "${env}" == "" ]; then \
docker-compose -p "${PROJECT}" down --remove-orphans; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml down --remove-orphans; \
fi
docker.ssh: clean
docker exec -it $(CONTAINER) bash
docker.stop: clean
@echo $(MESSAGE) "Stop Services: ${env}"
@if [ "${env}" == "" ]; then \
docker-compose -p "${PROJECT}" stop; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml stop; \
fi
docker.verify_network: ## Verify network
@if [ -z $$(docker network ls | grep $(DOCKER_NETWORK) | awk '{print $$2}') ]; then\
(docker network create $(DOCKER_NETWORK));\
fi
docker.up: clean
@echo $(MESSAGE) "Up Services: ${env}"
@if [ "${env}" == "" ]; then \
docker-compose -p "${PROJECT}" up --remove-orphans; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml up --remove-orphans; \
fi
docker.list: clean
@echo $(MESSAGE) "List Services: ${env}"
@if [ "${env}" == "" ]; then \
docker-compose -p "${PROJECT_DEV}" ps; \
else \
docker-compose -f docker-compose.yml -f "${PATH_DOCKER_COMPOSE}"/"${env}".yml ps; \
fi