-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
130 lines (103 loc) · 3.49 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
PROJECTS = $(wildcard ./client/* ./server/*)
OPA_IMAGE ?= docker.io/openpolicyagent/opa:latest
OPA ?= docker run -v ${PWD}/policies:/w/policies -w /w ${OPA_IMAGE}
entrypoint := "tickets/allow"
files := $(wildcard ./policies/*.rego ./policies/*.json)
policies/bundle.tar.gz: $(files)
$(OPA) build -o $@ $(files)
client/react/public/opa.wasm: $(files)
$(OPA) build -t wasm -o policies/tmp.tar.gz -e $(entrypoint) $(files)
tar zxf policies/tmp.tar.gz /policy.wasm
mv policy.wasm $@
rm policies/tmp.tar.gz
run:
(trap 'kill 0' SIGINT; \
$(MAKE) -C ./server/$(SERVER) run & \
$(MAKE) -C ./client/$(CLIENT) run)
run-go-html: SERVER = go
run-go-html: CLIENT = html
run-go-html: run
run-go-react: SERVER = go
run-go-react: CLIENT = react
run-go-react: run
run-java-html: SERVER = java
run-java-html: CLIENT = html
run-java-html: run
run-java-react: SERVER = java
run-java-react: CLIENT = react
run-java-react: run
run-node-html: SERVER = node
run-node-html: CLIENT = html
run-node-html: run
run-node-react: SERVER = node
run-node-react: CLIENT = react
run-node-react: run
run-csharp-html: SERVER = csharp
run-csharp-html: CLIENT = html
run-csharp-html: run
run-csharp-react: SERVER = csharp
run-csharp-react: CLIENT = react
run-csharp-react: run
run-aspnetcore-html: SERVER = aspnetcore
run-aspnetcore-html: CLIENT = html
run-aspnetcore-html: run
run-aspnetcore-react: SERVER = aspnetcore
run-aspnetcore-react: CLIENT = react
run-aspnetcore-react: run
.PHONY: clean
clean:
rm -rf dist
rm -rf build
rm -rf target
for proj in $(PROJECTS); do \
if [ -d $$proj ]; then \
echo "cleaning $$proj"; \
$(MAKE) -C $$proj clean; \
fi; \
done
tar-%: TARGET = tickethub-$(SERVER)-$(CLIENT)
tar-%:
echo "Copying $(TARGET)"
mkdir -p build/$(TARGET)
cp templates/* build/$(TARGET)/
mkdir -p build/$(TARGET)/client
cp -r client/$(CLIENT)/. build/$(TARGET)/client/
mkdir -p build/$(TARGET)/server
cp -r server/$(SERVER)/. build/$(TARGET)/server/
mkdir -p dist
tar -czvf dist/$(TARGET).tar.gz -C build/$(TARGET) .
package-go-html: SERVER = go
package-go-html: CLIENT = html
package-go-html: tar-go-html
package-go-react: SERVER = go
package-go-react: CLIENT = react
package-go-react: tar-go-react
package-java-html: SERVER = java
package-java-html: CLIENT = html
package-java-html: tar-java-html
package-java-react: SERVER = java
package-java-react: CLIENT = react
package-java-react: tar-java-react
package-node-html: SERVER = node
package-node-html: CLIENT = html
package-node-html: tar-node-html
package-node-react: SERVER = node
package-node-react: CLIENT = react
package-node-react: tar-node-react
package-csharp-html: SERVER = csharp
package-csharp-html: CLIENT = html
package-csharp-html: tar-csharp-html
package-csharp-react: SERVER = csharp
package-csharp-react: CLIENT = react
package-csharp-react: tar-csharp-react
package-aspnetcore-html: SERVER = aspnetcore
package-aspnetcore-html: CLIENT = html
package-aspnetcore-html: tar-aspnetcore-html
package-aspnetcore-react: SERVER = aspnetcore
package-aspnetcore-react: CLIENT = react
package-aspnetcore-react: tar-aspnetcore-react
package-all: package-node-html package-node-react package-java-html package-java-react package-csharp-html package-csharp-react package-aspnetcore-html package-aspnetcore-react package-go-html package-go-react
SERVER ?= node
reset-database:
psql -h localhost -p 5432 -U postgres -d postgres -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
psql -h localhost -p 5432 -U postgres -d postgres -f ./server/$(SERVER)/database/init.sql