This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (56 loc) · 2.08 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
.PHONY: build push clean test
export AWS_S3_BUCKET="iguide.plntr"
ifneq (${NOCACHE},)
NOCACHEFLAG=--no-cache
endif
build: bin/app static/big.txt bin/wrk
docker build ${NOCACHEFLAG} -t planitar/test-nginx .
push:
docker push planitar/test-nginx
clean:
rm -rf ./bin
rm -f static/big.txt
docker rmi -f planitar/test-nginx 2> /dev/null || true
test: build
docker run -d --name ng -p ::80 -p ::9000 \
-e "AWS_S3_BUCKET=${AWS_S3_BUCKET}" \
-e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" \
-e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" \
planitar/test-nginx
sleep 5s
/bin/bash -lc 'set -ex; \
NGINX_PORT=$$(docker inspect -f "{{ (index (index .NetworkSettings.Ports \"80/tcp\") 0).HostPort }}" ng); \
APP_PORT=$$(docker inspect -f "{{ (index (index .NetworkSettings.Ports \"9000/tcp\") 0).HostPort }}" ng); \
curl -f# http://${AWS_S3_BUCKET}.s3.amazonaws.com/small.txt >/dev/null; \
curl -f# http://localhost:$${APP_PORT}/small.txt >/dev/null; \
curl -f# http://localhost:$${APP_PORT}/view/small.txt >/dev/null; \
curl -f# http://localhost:$${NGINX_PORT}/ >/dev/null; \
curl -f# http://localhost:$${NGINX_PORT}/static/small.txt >/dev/null; \
curl -f# http://localhost:$${NGINX_PORT}/s3/small.txt >/dev/null; \
curl -f# http://localhost:$${NGINX_PORT}/app/small.txt >/dev/null; \
curl -f# http://localhost:$${NGINX_PORT}/app/view/small.txt >/dev/null; \
'; \
if [ $$? -ne 0 ]; then \
docker logs ng | tail; \
docker rm -f ng; \
false; \
fi
docker rm -f ng
bin/app:
mkdir -p bin
docker run --rm -v `pwd`/bin:/out planitar/dev-go /bin/bash -lc ' \
sudo apt-get update && \
sudo apt-get install -y bzr && \
go get "github.com/PlanitarInc/test-nginx/app" && \
cp $$GOPATH/bin/app /out \
'
bin/wrk:
mkdir -p bin
docker run --rm -v `pwd`/bin:/out planitar/dev-go /bin/bash -lc ' \
sudo apt-get update && sudo apt-get install -y libssl-dev && \
git clone https://github.com/wg/wrk && make -C wrk && \
cp ./wrk/wrk /out \
'
static/big.txt:
@# Generate ~5MB ascii file
cat /dev/urandom | tr -cd 'a-z0-9A-Z\n \t' | head -c 5242891 > $@