-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (108 loc) · 4.05 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
.PHONY: start stop build
COMPOSE=sudo docker-compose
DOCKER=sudo docker
# /env
CODE_PATH:= $(shell grep -E '^CODE_PATH' .env | cut -d '=' -f 2)
CONTAINER_PREFIX:= $(shell grep -E '^CONTAINER_PREFIX' .env | cut -d '=' -f 2)
HOST_PREFIX:= $(shell grep -E '^HOST_PREFIX' .env | cut -d '=' -f 2)
APP_NAME:= $(shell grep -E '^APP_NAME' .env | cut -d '=' -f 2)
NODE_01_DOMAIN:= $(shell grep -E '^NODE_01_DOMAIN' .env | cut -d '=' -f 2)
NODE_01_PORT:= $(shell grep -E '^NODE_01_PORT' .env | cut -d '=' -f 2)
NODE_02_DOMAIN:= $(shell grep -E '^NODE_02_DOMAIN' .env | cut -d '=' -f 2)
NODE_02_PORT_EXPOSE:= $(shell grep -E '^NODE_02_PORT_EXPOSE' .env | cut -d '=' -f 2)
# /*
# |--------------------------------------------------------------------------
# | Docker Network commands
# |--------------------------------------------------------------------------
# */
network:
$(DOCKER) network create traefik-net
network-list:
$(DOCKER) network ls
# /*
# |--------------------------------------------------------------------------
# | Docker Container start and stop commands
# |--------------------------------------------------------------------------
# */
start:
$(COMPOSE) up -d
start-utility:
$(COMPOSE) -f docker-web-utility.yml up -d
start-nodeapp:
$(COMPOSE) -f docker-node.yml up
start-nodeapp2:
$(COMPOSE) -f docker-node2.yml up
stop:
$(COMPOSE) -f docker-compose.yml down
stop-utility:
$(COMPOSE) -f docker-web-utility.yml down
stop-nodeapp:
$(COMPOSE) -f docker-node.yml down
stop-nodeapp2:
$(COMPOSE) -f docker-node2.yml down
# /*
# |--------------------------------------------------------------------------
# | Docker Build
# |--------------------------------------------------------------------------
# */
build:
$(COMPOSE) build --no-cache
$(COMPOSE) -f docker-web-utility.yml build
$(COMPOSE) -f docker-node.yml build
destroy:
@$(COMPOSE) rm -v -s -f
delete-volumes:
@$(DOCKER) volume rm $(shell $(DOCKER) volume ls -q)
# /*
# |--------------------------------------------------------------------------
# | Docker Cache clear
# |--------------------------------------------------------------------------
# */
prune:
@$(DOCKER) system prune -a
# /*
# |--------------------------------------------------------------------------
# | Utility commands
# |--------------------------------------------------------------------------
# */
list:
$(COMPOSE) ps -a
# ANSI escape codes for colors
RED := \033[0;31m
GREEN := \033[0;32m
RESET := \033[0m
BLUE := \033[0;34m
YELLOW := \033[0;33m
PURPLE := \033[0;35m
FIRE := \033[0;91m
links:
@echo "$(RED)http://${APP_NAME}.${HOST_PREFIX}/ (Laravel)"
@echo "$(GREEN)http://phpmyadmin-${CONTAINER_PREFIX}.${HOST_PREFIX}/ (PhpMyAdmin)"
@echo "$(GREEN)http://phpmyadmin-archive-${CONTAINER_PREFIX}.${HOST_PREFIX}/ (PhpMyAdmin-secondaryDB)"
@echo "$(RESET)http://meilisearch.${HOST_PREFIX}/ (Meilisearch)"
@echo "$(BLUE)http://localhost:8080/ (Traefik)"
@echo "$(YELLOW)http://portainer.${HOST_PREFIX}/ (Portainer)"
@echo "$(PURPLE)http://redis-insight.${HOST_PREFIX}/ (Redis Insight)"
@echo "$(FIRE)http://${NODE_01_DOMAIN}.${HOST_PREFIX}:${NODE_01_PORT}/ (Node App 01)"
@echo "$(FIRE)http://${NODE_02_DOMAIN}.${HOST_PREFIX}:${NODE_02_PORT_EXPOSE}/ (Node App 02)"
# run composer in contianer of name laravel-app and give the permission to laravel bootstrap and storage folder
composer:
$(COMPOSE) exec php-app composer install
$(COMPOSE) exec php-app chmod -R 777 ./
bash-php:
@$(DOCKER) exec -itu devuser $(CONTAINER_PREFIX)-app /bin/bash
bash-nginx:
@$(DOCKER) exec -it $(CONTAINER_PREFIX)-nginx /bin/bash
bash-redis:
@$(DOCKER) exec -it $(CONTAINER_PREFIX)-redis /bin/bash
bash-nodeapp01:
@$(DOCKER) exec -it $(CONTAINER_PREFIX)-nodeapp01 /bin/bash
bash-nodeapp02:
@$(DOCKER) exec -it $(CONTAINER_PREFIX)-nodeapp02 /bin/bash
# /*
# |--------------------------------------------------------------------------
# | Install Command
# |--------------------------------------------------------------------------
# */
install: network build start start-utility start-nodeapp composer links
uninstall: stop stop-utility stop-nodeapp destroy prune delete-volumes