-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (119 loc) · 4.27 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
ifeq ($(wildcard .solo),)
export COMPOSE_FILE = docker-compose.yml
else
export COMPOSE_FILE = docker-compose.solo.yml
endif
ifeq ($(wildcard .e),)
export VITE_CONFIG_DIRECTORY = /app/web/packages/teleport
export TOOL_FOLDER = tool
export LICENSE_FILE = ../teleport/empty.pem
else
export VITE_CONFIG_DIRECTORY = /app/e/web/teleport
export TOOL_FOLDER = e/tool
export LICENSE_FILE = ../../teleport/e/fixtures/license-all-features.pem
endif
## -- 🛟 Lifecycle --
.PHONY: start start-attach stop
## Starts all the Docker containers in detached mode % it waits for all containers to be running & healthy before finishing
start:
docker compose up --remove-orphans -d --wait
## Starts all Docker containers and attaches to them
start-attach:
docker compose up --remove-orphans
## Stops all the running Docker containers
stop:
docker compose stop
## -- 🧹 Building & cleaning --
.PHONY: build clean down
## Builds the Docker images
build:
docker compose build
## Removes all Docker containers and volumes
clean:
docker compose down -v --remove-orphans --rmi all
## Removes all the containers
down:
docker compose down
## -- 🔧 Setup --
.PHONY: cert setup
## Creates a local self signed certificate % for `go.teleport` and `*.teleport` via `mkcert`
cert:
mkdir -p certs && mkcert -cert-file certs/server.crt -key-file certs/server.key go.teleport "*.teleport" "*.go.teleport"
## Creates the initial admin user % alias for `make tctl users add admin --roles=editor,access --logins=root,ubuntu,ec2-user`
setup: TCTL_ARGS="users add admin --roles=editor,access --logins=root,ubuntu,ec2-user"
setup:
$(MAKE) tctl TCTL_ARGS=$(TCTL_ARGS)
## -- 📟 Commands --
.PHONY: frontend-logs frontend-shell logs tctl teleport-logs teleport-shell
frontend-logs: LOGS_ARGS="-f frontend"
## Shows and follows the logs from the frontend container % alias for `make logs -- -f frontend`
frontend-logs:
$(MAKE) logs LOGS_ARGS=$(LOGS_ARGS)
## Opens an interactive shell inside the frontend container
frontend-shell:
docker compose exec -it frontend /bin/bash
ifeq (logs,$(firstword $(MAKECMDGOALS)))
LOGS_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(LOGS_ARGS):;@:)
endif
## Runs `docker compose logs <command>` % if passing a flag such as `-f`, use `--`, such as `make logs -- -f frontend`
logs:
docker compose logs $(LOGS_ARGS)
ifeq (tctl,$(firstword $(MAKECMDGOALS)))
TCTL_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(TCTL_ARGS):;@:)
endif
## Runs `tctl <command>` inside the Teleport container
tctl:
docker compose exec go.teleport /bin/tctl $(TCTL_ARGS)
## Shows and follows the logs from the Teleport container % alias for `make logs -- -f go.teleport`
teleport-logs: LOGS_ARGS="-f go.teleport"
teleport-logs:
$(MAKE) logs LOGS_ARGS=$(LOGS_ARGS)
## Opens an interactive shell inside the Teleport container
teleport-shell:
docker compose exec -it go.teleport /bin/bash
## -- 🔧 Misc --
.PHONY: help
## Shows this help menu
help:
@echo "🚀 \033[94mTeleport Development Environment\033[39m"
@echo ''
@echo "Usage: \033[92mmake\033[39m \033[93m<target>\033[39m \033[2m[command]\033[22m"
@awk '{ \
if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":") - 1); \
if (helpMessage) { \
printf "\033[96m%-20s\033[0m \033[97m%s\033[2m%s\033[22m\n", \
helpCommand, helpMessage, description; \
helpMessage = ""; \
description = ""; \
} \
} else if ($$0 ~ /^## --/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 5); \
} else { \
headerTitle = substr($$0, 7); \
headerTitle = substr(headerTitle, 0, index(headerTitle, "-") - 1); \
print "\n\033[1m"headerTitle"\033[22m\n" \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 5); \
} else { \
helpMessage = substr($$0, 3); \
if (helpMessage ~ /%/) { \
helpMessage = substr(helpMessage, 0, index($$0, "%") - 3); \
description = substr($$0, index($$0, "%") + 2, length($$0)); \
description = "("description")"; \
} \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
description = ""; \
} \
}' \
$(MAKEFILE_LIST)