-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (57 loc) · 2.42 KB
/
Copy pathMakefile
File metadata and controls
72 lines (57 loc) · 2.42 KB
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
-include .env
#
##@ HELP
#
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
#
##@ DOCKER CONTAINER
#
start: ## Start nginx-proxy & dnsmasq & create needed files
@${MAKE} generate_dnsmasq_config;
@${MAKE} add_resolver;
@docker-compose up -d;
stop: ## Stop nginx-proxy & dnsmasq & remove files
@docker-compose down && \
${MAKE} remove_resolver && \
${MAKE} remove_dsnmasq_config \
;
logs: ## Show containers logs
@docker-compose logs -f;
generate_certificate: ## Generate a trusted certificate for local domain
@docker run --rm \
-v ${PWD}/certs:/opt/mkcert/data \
--workdir /opt/mkcert/data \
-e CAROOT=/opt/mkcert/data \
flesch/mkcert:latest \
mkcert -key-file ${LOCAL_DOMAIN}.key -cert-file ${LOCAL_DOMAIN}.crt *.${LOCAL_DOMAIN} ${SUB_DOMAINS} \
; \
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${PWD}/certs/rootCA.pem \
;
remove_certificate: ## Remove certificate generated for local domain
@rm ${PWD}/certs/${LOCAL_DOMAIN}.key && \
rm ${PWD}/certs/${LOCAL_DOMAIN}.crt && \
sudo security remove-trusted-cert -d ${PWD}/certs/rootCA.pem && \
rm ${PWD}/certs/rootCA-key.pem && \
rm ${PWD}/certs/rootCA.pem \
;
generate_dnsmasq_config: ## Generate dnsmasq config in host
@cp ${PWD}/dnsmasq.conf.dist ${PWD}/dnsmasq-ext.conf && \
cp ${PWD}/dnsmasq.conf.dist ${PWD}/dnsmasq-int.conf && \
sudo bash -c 'echo "address=/.${LOCAL_DOMAIN}/127.0.0.1" >> ${PWD}/dnsmasq-ext.conf' && \
sudo bash -c 'echo "address=/.${LOCAL_DOMAIN}/172.25.0.255" >> ${PWD}/dnsmasq-int.conf' \
;
remove_dsnmasq_config: ## Remove dnsmasq config generated in host
@rm ${PWD}/dnsmasq-ext.conf && rm ${PWD}/dnsmasq-int.conf;
add_resolver: ## Add resolver for local domain in host
@sudo mkdir -p /etc/resolver && sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/${LOCAL_DOMAIN}';
remove_resolver: ## Remove resolver for local domain in host
@sudo rm /etc/resolver/${LOCAL_DOMAIN};
terminal: ## Enter in nginx-proxy terminal
@docker exec -it nginx-proxy /bin/bash;
terminal-dnsmasq-ext: ## Enter in dnsmasq for host terminal
@docker exec -it dnsmasq-ext /bin/sh;
terminal-dnsmasq-int: ## Enter in dnsmasq for containers terminal
@docker exec -it dnsmasq-int /bin/sh;