-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
67 lines (43 loc) · 2.06 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
VERSION := $(shell grep VERSION src/handler.lua | awk -F'=' '{print $$2}'|tr -d '[:space:]')
NAME := $(shell basename $${PWD})
UID := $(shell id -u)
GID := $(shell id -g)
SUMMARY := $(shell sed -n '/^summary: /s/^summary: //p' README.md)
export UID GID NAME VERSION
build: validate
@find . -type f -iname "*lua~" -exec rm -f {} \;
@docker run --rm \
-v ${PWD}:/plugin \
kong /bin/sh -c "apk add --no-cache zip > /dev/null 2>&1 ; cd /plugin ; luarocks make > /dev/null 2>&1 ; luarocks pack ${NAME} 2> /dev/null; chown ${UID}:${GID} *.rock"
@mkdir -p dist
@mv *.rock dist/
@echo -e '\n\n Check "dist" folder \n\n\n'
validate:
@if [ "x$${VERSION}" == "x" ]; then \
echo -e "\n\nNo VERSION found in handler.lua;\nPlease set it in your object that extends the base_plugin.\nEx: plugin.VERSION = \"0.1.0-1\"\n\n"; \
exit 1 ;\
fi
@if [ ! -f ${NAME}-${VERSION}.rockspec ]; then \
make rockspec; \
fi
rockspec:
@echo -e 'package = "<NAME>"\nversion = "<VERSION>"\n\nsource = {\n url = "[email protected]:carnei-ro/${NAME}.git",\n branch = "master"\n}\n\ndescription = {\n summary = "<SUMMARY>",\n}\n\ndependencies = {\n "lua ~> 5.1"\n}\n\nbuild = {\n type = "builtin",\n modules = {' > rockspec
@find src/ -type f -iname "*.lua" -exec bash -c 'echo -e \ \ \ \ [\"`echo $${1} | sed -e 's/.lua//g' -e 's/src\//g' | tr '/' '.' | sed "s/^/kong.plugins.$${NAME}/g" `\"] = \"$${1}\",' _ {} \; >> rockspec
@echo -e " }\n}" >> rockspec
@sed -e "s/<NAME>/${NAME}/" -e "s/<SUMMARY>/${SUMMARY}/" -e "s/<VERSION>/${VERSION}/" rockspec > ${NAME}-${VERSION}.rockspec
@rm -f rockspec
clean:
@rm -rf *.rock *.rockspec dist shm
@find . -type f -iname "*lua~" -exec rm -f {} \;
@docker-compose down -v
start: validate
@docker-compose up -d
stop:
@docker-compose down
kong-logs:
@docker logs -f `docker ps -qf name=${NAME}_kong_1` 2>&1 || true
kong-bash:
@docker exec -it `docker ps -qf name=${NAME}_kong_1` bash || true
kong-reload:
@docker exec -it `docker ps -qf name=${NAME}_kong_1` bash -c "/usr/local/bin/kong reload"
reconfigure: clean start kong-logs