-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (69 loc) · 1.76 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
SHELL = /bin/bash
REQUIRED = docker docker-compose
K := $(foreach exec,$(REQUIRED),\
$(if $(shell which $(exec)),OK,$(error "$(exec) not found. Please install first.")))
default: help
## Targets for the dev-proxy
##
## General
## -------
##
## help Print commands help.
.PHONY: help
help: Makefile
@sed -n 's/^##//p' $<
## up Start the dev-proxy.
.PHONY: up
up:
@docker compose up -d
## down Stop the dev-proxy.
.PHONY: down
down:
@docker-compose down
## teardown Cleanup everything.
.PHONY: teardown
teardown: down
@docker network rm dev-proxy
## logs Tail dev-proxy logs.
.PHONY: logs
logs:
@docker-compose logs -f
## setup Onetime setup for the dev-proxy.
.PHONY: setup
setup:
@docker network create dev-proxy >/dev/null 2>&1 || echo "Network already created"
@mkdir -p certs/
@mkcert -install
@if [ -f "certs/local-cert.pem" ] && [ -f "certs/local-key.pem" ]; then \
echo "Certificate for '$$domain' already present."; \
else \
mkcert -cert-file certs/local-cert.pem -key-file certs/local-key.pem localhost 127.0.0.1 ::1; \
fi
@make .install-domains
@echo "Setup complete."
@echo
@echo "Please add the domain mapping to /etc/hosts or setup dnsmasq."
## add Add a new domain to the dev-proxy.
.PHONY: add
add:
@scripts/install_domain $$domain
@echo "$$domain" >> domains
@echo "$$domain added successfully"
## remove Remove a domain from the dev-proxy.
.PHONY: remove
remove:
@scripts/uninstall_domain $$domain
@cp domains _domains
@sed "s/$$domain//g" _domains | grep -v "^$$" > domains
@rm _domains
@echo
@echo "$$domain removed successfully"
PHONY: .install-domains
.install-domains:
@if [ -f "domains" ]; then \
while read -r domain; do \
scripts/install_domain $$domain; \
done < domains; \
else \
echo "No domains defined"; \
fi