1
1
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
2
2
PROJECT_PATH := $(patsubst % /,% ,$(dir $(MKFILE_PATH ) ) )
3
+ SHELL = /usr/bin/env bash -o pipefail
4
+ .SHELLFLAGS = -ec
3
5
.DEFAULT_GOAL := help
4
- DOCKER_COMPOSE = docker-compose
6
+
5
7
DOCKER ?= $(shell which docker 2> /dev/null || echo "docker")
6
8
REGISTRY ?= quay.io/3scale
7
9
export TEST_NGINX_BINARY ?= openresty
8
10
NGINX = $(shell which $(TEST_NGINX_BINARY ) )
9
- SHELL =/bin/bash -o pipefail
10
11
11
12
NPROC ?= $(firstword $(shell nproc 2>/dev/null) 1)
12
13
@@ -22,6 +23,8 @@ DEVEL_DOCKER_COMPOSE_VOLMOUNT_MAC_FILE ?= docker-compose-devel-volmount-mac.yml
22
23
DEVEL_DOCKER_COMPOSE_VOLMOUNT_DEFAULT_FILE ?= docker-compose-devel-volmount-default.yml
23
24
24
25
PROVE_DOCKER_COMPOSE_FILE ?= docker-compose.prove.yml
26
+ FORWARD_PROXY_DOCKER_COMPOSE_FILE ?= docker-compose.forward-proxy.yml
27
+ UPSTREAM_TLS_DOCKER_COMPOSE_FILE ?= docker-compose.upstream-tls.yml
25
28
26
29
DOCKER_VOLUME_NAME ?= apicast-local-volume
27
30
@@ -143,7 +146,7 @@ prove: $(ROVER) dependencies nginx ## Test nginx
143
146
prove-docker : export IMAGE_NAME ?= $(DEVEL_IMAGE )
144
147
prove-docker : # # Test nginx inside docker
145
148
make -C $(PROJECT_PATH ) -f $(MKFILE_PATH ) apicast-source
146
- $(DOCKER_COMPOSE ) -f $(PROVE_DOCKER_COMPOSE_FILE ) run --rm -T \
149
+ $(DOCKER ) compose -f $(PROVE_DOCKER_COMPOSE_FILE ) run --rm -T \
147
150
-v $(DOCKER_VOLUME_NAME ) :/opt/app-root/src prove | \
148
151
awk ' /Result: NOTESTS/ { print "FAIL: NOTESTS"; print; exit 1 }; { print }'
149
152
@@ -158,43 +161,51 @@ push: ## Push image to the registry
158
161
bash : export IMAGE_NAME ?= $(RUNTIME_IMAGE )
159
162
bash : export SERVICE = gateway
160
163
bash : # # Run bash inside the runtime image
161
- $(DOCKER_COMPOSE ) run --user=root --rm --entrypoint=bash $(SERVICE )
164
+ $(DOCKER ) compose run --user=root --rm --entrypoint=bash $(SERVICE )
162
165
163
166
gateway-logs : export IMAGE_NAME = does-not-matter
164
167
gateway-logs :
165
- $(DOCKER_COMPOSE ) logs gateway
168
+ $(DOCKER ) compose logs gateway
166
169
167
170
opentelemetry-gateway : # # run gateway instrumented with opentelemetry
168
- $(DOCKER_COMPOSE ) run opentelemetry-instrumented-gateway
171
+ $(DOCKER ) compose run opentelemetry-instrumented-gateway
169
172
170
173
opentracing-gateway : # # run gateway instrumented with opentracing
171
- $(DOCKER_COMPOSE ) run opentracing-instrumented-gateway
174
+ $(DOCKER ) compose run opentracing-instrumented-gateway
175
+
176
+ # Environment described in ./examples/forward-proxy
177
+ forward-proxy-gateway : # # run gateway configured to run along with a forward proxy
178
+ $(DOCKER ) compose -f $(FORWARD_PROXY_DOCKER_COMPOSE_FILE ) run gateway
179
+
180
+ # Environment described in ./examples/tlsv1.3-upstream
181
+ upstream-tls-gateway : # # run gateway configured to access upstream powered with TLS
182
+ $(DOCKER ) compose -f $(UPSTREAM_TLS_DOCKER_COMPOSE_FILE ) run gateway
172
183
173
184
test-runtime-image : export IMAGE_NAME ?= $(RUNTIME_IMAGE )
174
185
test-runtime-image : clean-containers # # Smoke test the runtime image. Pass any docker image in IMAGE_NAME parameter.
175
- $(DOCKER_COMPOSE ) --version
176
- $(DOCKER_COMPOSE ) run --rm --user 100001 gateway apicast -l -d
186
+ $(DOCKER ) compose --version
187
+ $(DOCKER ) compose run --rm --user 100001 gateway apicast -l -d
177
188
@echo -e $(SEPARATOR )
178
- $(DOCKER_COMPOSE ) run --rm --user 100002 -e APICAST_CONFIGURATION_LOADER=boot -e THREESCALE_PORTAL_ENDPOINT=https://echo-api.3scale.net gateway bin/apicast -d
189
+ $(DOCKER ) compose run --rm --user 100002 -e APICAST_CONFIGURATION_LOADER=boot -e THREESCALE_PORTAL_ENDPOINT=https://echo-api.3scale.net gateway bin/apicast -d
179
190
@echo -e $(SEPARATOR )
180
- $(DOCKER_COMPOSE ) run --rm test sh -c ' sleep 5 && curl --fail http://gateway:8090/status/live'
191
+ $(DOCKER ) compose run --rm test sh -c ' sleep 5 && curl --fail http://gateway:8090/status/live'
181
192
@echo -e $(SEPARATOR )
182
- $(DOCKER_COMPOSE ) run --rm --user 100001 gateway bin/apicast --test
193
+ $(DOCKER ) compose run --rm --user 100001 gateway bin/apicast --test
183
194
@echo -e $(SEPARATOR )
184
- $(DOCKER_COMPOSE ) run --rm --user 100001 gateway bin/apicast --test --dev
195
+ $(DOCKER ) compose run --rm --user 100001 gateway bin/apicast --test --dev
185
196
@echo -e $(SEPARATOR )
186
- $(DOCKER_COMPOSE ) run --rm --user 100001 gateway bin/apicast --daemon
197
+ $(DOCKER ) compose run --rm --user 100001 gateway bin/apicast --daemon
187
198
@echo -e $(SEPARATOR )
188
- $(DOCKER_COMPOSE ) run --rm test bash -c ' for i in {1..5}; do curl --fail http://gateway:8090/status/live && break || sleep 1; done'
189
- $(DOCKER_COMPOSE ) logs gateway
199
+ $(DOCKER ) compose run --rm test bash -c ' for i in {1..5}; do curl --fail http://gateway:8090/status/live && break || sleep 1; done'
200
+ $(DOCKER ) compose logs gateway
190
201
@echo -e $(SEPARATOR )
191
- $(DOCKER_COMPOSE ) run --rm test curl --fail -X PUT http://gateway:8090/config --data ' {"services":[{"id":42}]}'
202
+ $(DOCKER ) compose run --rm test curl --fail -X PUT http://gateway:8090/config --data ' {"services":[{"id":42}]}'
192
203
@echo -e $(SEPARATOR )
193
- $(DOCKER_COMPOSE ) run --rm test curl --fail http://gateway:8090/status/ready
204
+ $(DOCKER ) compose run --rm test curl --fail http://gateway:8090/status/ready
194
205
@echo -e $(SEPARATOR )
195
- $(DOCKER_COMPOSE ) run --rm test curl --fail -X POST http://gateway:8090/boot
206
+ $(DOCKER ) compose run --rm test curl --fail -X POST http://gateway:8090/boot
196
207
@echo -e $(SEPARATOR )
197
- $(DOCKER_COMPOSE ) run --rm gateway bin/apicast -c http://echo-api.3scale.net -d -b
208
+ $(DOCKER ) compose run --rm gateway bin/apicast -c http://echo-api.3scale.net -d -b
198
209
199
210
$(PROJECT_PATH ) /lua_modules $(PROJECT_PATH ) /local $(PROJECT_PATH ) /.cpanm $(PROJECT_PATH ) /vendor/cache $(PROJECT_PATH ) /.cache :
200
211
mkdir -p $@
@@ -207,9 +218,9 @@ development: GROUP := $(shell id -g $(USER))
207
218
endif
208
219
development : # # Run bash inside the development image
209
220
@echo " Running on $( os) "
210
- - $(DOCKER_COMPOSE ) -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) up -d
221
+ - $(DOCKER ) compose -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) up -d
211
222
@ # https://github.com/moby/moby/issues/33794#issuecomment-312873988 for fixing the terminal width
212
- $(DOCKER_COMPOSE ) -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) exec -e COLUMNS=" ` tput cols` " -e LINES=" ` tput lines` " --user $(USER ) :$(GROUP ) development bash
223
+ $(DOCKER ) compose -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) exec -e COLUMNS=" ` tput cols` " -e LINES=" ` tput lines` " --user $(USER ) :$(GROUP ) development bash
213
224
214
225
stop-development : clean-containers # # Stop development environment
215
226
@@ -233,9 +244,11 @@ lua_modules/bin/rover:
233
244
dependencies : dep_folders lua_modules carton # # Install project dependencies
234
245
235
246
clean-containers :
236
- - $(DOCKER_COMPOSE ) down --volumes --remove-orphans
237
- - $(DOCKER_COMPOSE ) -f $(PROVE_DOCKER_COMPOSE_FILE ) down --volumes --remove-orphans
238
- - $(DOCKER_COMPOSE ) -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) down --volumes --remove-orphans
247
+ $(DOCKER ) compose down --volumes --remove-orphans
248
+ $(DOCKER ) compose -f $(PROVE_DOCKER_COMPOSE_FILE ) down --volumes --remove-orphans
249
+ $(DOCKER ) compose -f $(DEVEL_DOCKER_COMPOSE_FILE ) -f $(DEVEL_DOCKER_COMPOSE_VOLMOUNT_FILE ) down --volumes --remove-orphans
250
+ $(DOCKER ) compose -f $(FORWARD_PROXY_DOCKER_COMPOSE_FILE ) down --volumes --remove-orphans
251
+ $(DOCKER ) compose -f $(UPSTREAM_TLS_DOCKER_COMPOSE_FILE ) down --volumes --remove-orphans
239
252
240
253
clean-deps : # # Remove all local dependency folders
241
254
- rm -rf $(PROJECT_PATH ) /lua_modules $(PROJECT_PATH ) /local $(PROJECT_PATH ) /.cpanm $(PROJECT_PATH ) /vendor/cache $(PROJECT_PATH ) /.cache :
@@ -270,12 +283,12 @@ benchmark: export COMPOSE_PROJECT_NAME = apicast-benchmark
270
283
benchmark : export WRK_REPORT ?= $(IMAGE_TAG ) .csv
271
284
benchmark : export DURATION ?= 300
272
285
benchmark :
273
- - $(DOCKER_COMPOSE ) up --force-recreate -d apicast
274
- $(DOCKER_COMPOSE ) run curl
286
+ - $(DOCKER ) compose up --force-recreate -d apicast
287
+ $(DOCKER ) compose run curl
275
288
# # warmup round for $(DURATION)/10 seconds
276
- DURATION=$$(( $(DURATION ) / 10 ) ) $(DOCKER_COMPOSE ) run wrk
289
+ DURATION=$$(( $(DURATION ) / 10 ) ) $(DOCKER ) compose run wrk
277
290
# # run the real benchmark for $(DURATION) seconds
278
- $(DOCKER_COMPOSE ) run wrk
291
+ $(DOCKER ) compose run wrk
279
292
280
293
# Check http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
281
294
help : # # Print this help
0 commit comments