-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (97 loc) · 4.49 KB
/
Copy pathMakefile
File metadata and controls
121 lines (97 loc) · 4.49 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
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
# GZCTF platform — docker-compose helper targets.
# Pure platform ops; for challenge authoring use gzcli separately.
SUDO ?=
COMPOSE = ${SUDO} docker compose -f compose.yml -f compose.traefik.yml
COMPOSE_BARE = ${SUDO} docker compose -f compose.yml -f compose.standalone.yml
.PHONY: help wizard setup init-config platform-up platform-up-no-traefik platform-down platform-restart platform-clean \
platform-logs gzctf-logs db-logs cache-logs traefik-logs traefik-restart \
flush-cache pull pull-no-traefik pull-gzctf update update-no-traefik update-gzctf
help:
@echo "GZCTF platform make targets:"
@echo ""
@echo " wizard Interactive first-time setup (writes .env + appsettings.json)"
@echo " setup One-time bootstrap: create the external `traefik` + `challenges` networks"
@echo " init-config Generate compose/appsettings.json from the example + .env (auto-runs on platform-up)"
@echo " platform-up Start gzctf + db + cache + traefik (auto-runs init-config if config missing)"
@echo " platform-up-no-traefik Start gzctf + db + cache only, expose gzctf on host port 8080"
@echo " platform-down Stop everything (keeps volumes)"
@echo " platform-restart Restart all services"
@echo " platform-clean Stop everything AND drop volumes (data loss)"
@echo " pull Pull the latest image for every service"
@echo ""
@echo " platform-logs Tail logs for all services"
@echo " gzctf-logs Tail gzctf only"
@echo " db-logs Tail postgres only"
@echo " cache-logs Tail redis only"
@echo " traefik-logs Tail traefik only"
@echo " traefik-restart Restart traefik only"
@echo ""
@echo " flush-cache Flush redis (rebuilds scoreboard cache on next request)"
@echo ""
@echo "Updating images:"
@echo " pull-gzctf Pull latest dimasmaualana/gzctf:develop (no restart)"
@echo " pull Pull latest of every image incl. traefik (no restart)"
@echo " pull-no-traefik Pull latest of gzctf + postgres + redis (no restart)"
@echo " update-gzctf Pull gzctf + recreate just the gzctf container"
@echo " update Pull all + recreate any container with a changed image (traefik mode)"
@echo " update-no-traefik Same as 'update' but for the standalone (no-traefik) mode"
@echo ""
@echo "First-time setup:"
@echo " make wizard && make setup && make platform-up"
@echo " (the wizard prompts for PUBLIC_ENTRY + optional SMTP/captcha, generates an admin password)"
wizard:
@sh scripts/wizard.sh
setup:
@echo "Creating external docker networks 'traefik' + 'challenges' (idempotent)..."
@${SUDO} docker network inspect traefik >/dev/null 2>&1 \
|| ${SUDO} docker network create traefik
@${SUDO} docker network inspect challenges >/dev/null 2>&1 \
|| ${SUDO} docker network create challenges
@echo "Done. Run 'make platform-up' to start the platform."
# Generates compose/appsettings.json from the shipped example on
# first run. Idempotent — bails silently if the file already exists.
init-config:
@sh scripts/init-config.sh
platform-up: init-config
(cd compose && ${COMPOSE} up -d)
# Bring up gzctf + db + cache only — no traefik, no TLS. gzctf is
# reachable on http://<host>:8080.
platform-up-no-traefik: init-config
(cd compose && ${COMPOSE_BARE} up -d)
platform-down:
(cd compose && ${COMPOSE} down)
platform-restart: platform-down platform-up
platform-clean:
(cd compose && ${COMPOSE} down -v)
pull:
(cd compose && ${COMPOSE} pull)
pull-no-traefik:
(cd compose && ${COMPOSE_BARE} pull)
pull-gzctf:
(cd compose && ${COMPOSE} pull gzctf)
# 'up -d' recreates any container whose image digest changed and
# leaves the rest alone. Safe to run while the platform is live —
# only gzctf goes down briefly if its image was updated.
update: pull
(cd compose && ${COMPOSE} up -d)
update-no-traefik: pull-no-traefik
(cd compose && ${COMPOSE_BARE} up -d)
# Targeted refresh: only touch the gzctf container; leave traefik
# and the DB/cache running. Works in either traefik or standalone
# mode since both files describe the same gzctf service.
update-gzctf: pull-gzctf
(cd compose && ${COMPOSE} up -d --no-deps gzctf)
platform-logs:
(cd compose && ${COMPOSE} logs -f)
gzctf-logs:
(cd compose && ${COMPOSE} logs -f gzctf)
db-logs:
(cd compose && ${COMPOSE} logs -f db)
cache-logs:
(cd compose && ${COMPOSE} logs -f cache)
traefik-logs:
(cd compose && ${COMPOSE} logs -f traefik)
traefik-restart:
(cd compose && ${COMPOSE} restart traefik)
flush-cache:
(cd compose && ${COMPOSE} exec cache redis-cli FLUSHALL)