-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathMakefile
45 lines (35 loc) · 1.51 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
.PHONY: help check clean fetch-dependencies docker-build build-lambda-package
help:
@python -c 'import fileinput,re; \
ms=filter(None, (re.search("([a-zA-Z_-]+):.*?## (.*)$$",l) for l in fileinput.input())); \
print("\n".join(sorted("\033[36m {:25}\033[0m {}".format(*m.groups()) for m in ms)))' $(MAKEFILE_LIST)
check: ## print versions of required tools
@docker --version
@docker-compose --version
@python3 --version
clean: ## delete pycache, build files
@rm -rf build build.zip
@rm -rf __pycache__
fetch-dependencies: ## download chromedriver, headless-chrome to `./bin/`
@mkdir -p bin/
# Get chromedriver
curl -SL https://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip -d bin/
# Get Headless-chrome
curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-29/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
unzip headless-chromium.zip -d bin/
# Clean
@rm headless-chromium.zip chromedriver.zip
docker-build: ## create Docker image
docker-compose build
docker-run: ## run `src.lambda_function.lambda_handler` with docker-compose
docker-compose run lambda src.lambda_function.lambda_handler
build-lambda-package: clean fetch-dependencies ## prepares zip archive for AWS Lambda deploy (-> build/build.zip)
mkdir build
cp -r src build/.
cp -r bin build/.
cp -r lib build/.
pip install -r requirements.txt -t build/lib/.
cd build; zip -9qr build.zip .
cp build/build.zip .
rm -rf build