-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
61 lines (54 loc) · 2.15 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
GATEWAY_IMAGE=ghcr.io/infratographer/api-gateway-image
GATEWAY_IMAGE_TAG?=latest
KRAKEND_PORT?=8080
LOADBALANCER_API_BACKEND_HOSTS?=http://host.docker.internal:7608
# Krakend flexible configuration
# https://www.krakend.io/docs/configuration/flexible-config/
FC_ENABLE?=1
FC_SETTINGS?=/etc/krakend/settings
FC_PARTIALS?=/etc/krakend/partials
FC_TEMPLATES?=/etc/krakend/templates
FC_OUT?=/workdir/krakend.yml
.PHONY: help
help: Makefile ## Print help
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/:.*##/#/' | column -c 2 -t -s#
.PHONY: check
check: ## Run verification on krakend tmpl config
@echo "Verifying the endpoints and config"
@docker run \
--rm -t \
-v $(PWD):/workdir \
-v $(PWD)/krakendcfg:/etc/krakend/ \
-e KRAKEND_PORT=${KRAKEND_PORT} \
-e LOADBALANCER_API_BACKEND_HOSTS=${LOADBALANCER_API_BACKEND_HOSTS} \
-e FC_ENABLE=${FC_ENABLE} \
-e FC_SETTINGS=${FC_SETTINGS} \
-e FC_PARTIALS=${FC_PARTIALS} \
-e FC_TEMPLATES=${FC_TEMPLATES} \
-e FC_OUT=${FC_OUT} \
devopsfaith/krakend check -dtc krakend.tmpl
.PHONY: gateway-image
gateway-image: check ## Generate the krakend configuration and build the image
@echo "building API image..."
@docker build --no-cache -t $(GATEWAY_IMAGE):$(GATEWAY_IMAGE_TAG) -f Dockerfile .
@echo "endpoints image available in $(GATEWAY_IMAGE):$(GATEWAY_IMAGE_TAG)"
.PHONY: run-local
run-local: gateway-image ## Build and run local api gateway
@echo Starting api gateway...
@docker run --rm \
-v $(PWD)/krakendcfg:/etc/krakend/ \
-p ${KRAKEND_PORT}:${KRAKEND_PORT} \
-e LOADBALANCER_API_BACKEND_HOSTS=${LOADBALANCER_API_BACKEND_HOSTS} \
-e FC_ENABLE=${FC_ENABLE} \
-e FC_SETTINGS=${FC_SETTINGS} \
-e FC_PARTIALS=${FC_PARTIALS} \
-e FC_TEMPLATES=${FC_TEMPLATES} \
$(GATEWAY_IMAGE):$(GATEWAY_IMAGE_TAG)
.PHONY: dev-check
dev-check: ## Run lintings and verification on endpoints in the devcontainer
@echo "Verifying the endpoints and config ..."
@krakend check -dtc /workspace/krakendcfg/krakend.tmpl
.PHONY: dev-run
dev-run: dev-check ## Run the gateway in the devcontainer
@echo "* Running a local container with the generated configuration..."
@krakend run -c /workspace/krakendcfg/krakend.tmpl