forked from TeslaGov/ngx-http-auth-jwt-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (62 loc) · 2.39 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
SHELL += -eu
BLUE := \033[0;34m
GREEN := \033[0;32m
RED := \033[0;31m
NC := \033[0m
DOCKER_ORG_NAME ?= teslagov
DOCKER_IMAGE_NAME ?= jwt-nginx
COMPOSE_PROJECT_NAME ?= jwt-nginx-test
NGINX_VERSION ?= 1.22.0
.PHONY: all
all:
@$(MAKE) build-nginx
@$(MAKE) start-nginx
@$(MAKE) test
.PHONY: build-nginx
build-nginx:
@echo "${BLUE} Building...${NC}"
@docker image pull debian:bullseye-slim
@docker image pull nginx:${NGINX_VERSION}
@docker image build -t ${DOCKER_ORG_NAME}/${DOCKER_IMAGE_NAME}:latest -t ${DOCKER_ORG_NAME}/${DOCKER_IMAGE_NAME}:${NGINX_VERSION} --build-arg NGINX_VERSION=${NGINX_VERSION} . ; \
SUCCESS=$$? ; \
docker rmi $$(docker images --filter=label=stage=builder --quiet); \
if [ "$$SUCCESS" -ne 0 ] ; \
then echo "${RED} Build failed ${NC}"; \
else echo "${GREEN}✓ Successfully built NGINX module ${NC}"; fi
.PHONY: rebuild-nginx
rebuild-nginx:
@echo "${BLUE} Rebuilding...${NC}"
@docker image pull debian:bullseye-slim
@docker image pull nginx:${NGINX_VERSION}
@docker image build -t ${DOCKER_ORG_NAME}/${DOCKER_IMAGE_NAME}:latest -t ${DOCKER_ORG_NAME}/${DOCKER_IMAGE_NAME}:${NGINX_VERSION} --build-arg NGINX_VERSION=${NGINX_VERSION} --no-cache .; \
SUCCESS=$$? ; \
docker rmi $$(docker images --filter=label=stage=builder --quiet); \
if [ "$$SUCCESS" -ne 0 ] ; \
then echo "${RED} Build failed ${NC}"; \
else echo "${GREEN}✓ Successfully rebuilt NGINX module ${NC}"; fi
.PHONY: stop-nginx
stop-nginx:
docker stop "${DOCKER_IMAGE_NAME}"
.PHONY: start-nginx
start-nginx:
docker run --rm --name "${DOCKER_IMAGE_NAME}" -d -p 8000:8000 ${DOCKER_ORG_NAME}/${DOCKER_IMAGE_NAME}
.PHONY: cp-bin
cp-bin: start-nginx
rm -rf bin
mkdir -p bin
docker exec jwt-nginx sh -c "tar -chf - \
/usr/lib64/nginx/modules/ngx_http_auth_jwt_module.so \
/usr/lib/x86_64-linux-gnu/libjansson.so.* \
/usr/lib/x86_64-linux-gnu/libjwt.*" 2>/dev/null | tar -xf - -C bin &>/dev/null
.PHONY: build-test-runner
build-test-runner:
IMAGE_VERSION=${NGINX_VERSION} docker compose -f ./docker-compose-test.yml build
.PHONY: rebuild-test-runner
rebuild-test-runner:
IMAGE_VERSION=${NGINX_VERSION} docker compose -f ./docker-compose-test.yml build --no-cache
.PHONY: test
test:
IMAGE_VERSION=${NGINX_VERSION} docker compose -f ./docker-compose-test.yml up --no-start
docker start ${COMPOSE_PROJECT_NAME}-nginx-1
docker start -a ${COMPOSE_PROJECT_NAME}-runner-1
docker compose -f ./docker-compose-test.yml down