-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (114 loc) · 3.18 KB
/
Makefile
File metadata and controls
149 lines (114 loc) · 3.18 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
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
147
148
149
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org,direct
SHELL := /bin/bash
BACKEND_DIR = backend
API_NAME = mapctf-api
MAP_NAME = mapctf-map
.PHONY: build static clean api run_api map run_map
# Build code according to caller OS and architecture
build:
make api map
# Build API
api:
$(MAKE) -C $(BACKEND_DIR) api
# Build map
map:
$(MAKE) -C $(BACKEND_DIR) map
# Run API server locally
run_api:
$(MAKE) -C $(BACKEND_DIR) run
# Clean API
clean-api:
$(MAKE) -C $(BACKEND_DIR) clean
# Run map server locally
run_map:
$(MAKE) -C $(BACKEND_DIR) run
# Clean map
clean-map:
$(MAKE) -C $(BACKEND_DIR) clean
# Delete all compiled binaries
clean:
make clean-api
make clean-map
# Display systemd logs for API server
logs_api:
sudo journalctl -f -t $(API_NAME)
# Display systemd logs for map server
logs_map:
sudo journalctl -f -t $(MAP_NAME)
# Install API
# optional DEST=destination_path
install:
make clean
make build
make install_api
make install_map
# Install API server and restart service
# optional DEST=destination_path
install_api:
sudo systemctl stop $(API_NAME)
sudo cp $(OUTPUT)/$(API_NAME) $(DEST)
sudo systemctl start $(API_NAME)
# Install map server and restart service
# optional DEST=destination_path
install_map:
sudo systemctl stop $(MAP_NAME)
sudo cp $(OUTPUT)/$(MAP_NAME) $(DEST)
sudo systemctl start $(MAP_NAME)
# Display docker logs for API server
docker_dev_logs_api:
docker logs -f $(API_NAME)-dev
# Display docker logs for map server
docker_dev_logs_map:
docker logs -f $(MAP_NAME)-dev
# Display docker logs for postgresql server
docker_dev_logs_postgresql:
docker logs -f mapctf-postgres-dev
# Display docker logs for redis server
docker_dev_logs_redis:
docker logs -f mapctf-redis-dev
# Docker shell into API server
docker_dev_shell_api:
docker exec -it $(API_NAME)-dev /bin/bash
# Docker shell into map server
docker_dev_shell_map:
docker exec -it $(MAP_NAME)-dev /bin/bash
# Docker shell into postgresql server
docker_dev_shell_postgres:
docker exec -it mapctf-postgres-dev /bin/bash
# Docker shell into redis server
docker_dev_shell_redis:
docker exec -it mapctf-redis-dev /bin/sh
# Build dev docker containers and run them
docker_dev_build:
ifeq (,$(wildcard ./.env))
$(error Missing .env file)
endif
docker-compose -f docker-compose-dev.yml build
# Build and run dev docker containers
make docker_dev:
make docker_dev_build
make docker_dev_up
# Run docker containers
docker_dev_up:
docker-compose -f docker-compose-dev.yml up
up-backend:
docker-compose -f docker-compose-dev.yml up mapctf-postgres mapctf-redis
# Takes down docker containers
docker_dev_down:
docker-compose -f docker-compose-dev.yml down
# Deletes all mapctf docker images
docker_dev_clean:
docker images --format table | grep mapctf | awk '{print $$3}' | xargs -rI {} docker rmi -f {}
# Rebuild only the API server
docker_dev_rebuild_api:
docker-compose -f docker-compose-dev.yml up --force-recreate --no-deps -d --build $(API_NAME)
# Rebuild only the map server
docker_dev_rebuild_map:
docker-compose -f docker-compose-dev.yml up --force-recreate --no-deps -d --build $(MAP_NAME)
# Run linter
lint:
golangci-lint run
# Test with coverage
test:
$(MAKE) -C $(BACKEND_DIR) test