-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
68 lines (56 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
PLATFORM ?= linux/amd64
RUNTIME ?= 3.12
TEST_FILENAME ?= report.pdf
DOCKER_RUN=docker run --rm --platform=${PLATFORM} -e RUNTIME_VERSION=${RUNTIME}
.PHONY: stack.deploy.weasyprint clean test.start.container test.print.report
all: build/weasyprint-layer-python$(RUNTIME).zip
build/weasyprint-layer-python$(RUNTIME).zip: weasyprint/layer_builder.sh \
build/fonts-layer.zip \
| _build
${DOCKER_RUN} \
-v `pwd`/weasyprint:/out \
--entrypoint "/out/layer_builder.sh" \
-t public.ecr.aws/lambda/python:${RUNTIME}
mv -f ./weasyprint/layer.zip ./build/weasyprint-layer-python${RUNTIME}-no-fonts.zip
cd build && rm -rf ./opt && mkdir opt \
&& unzip fonts-layer.zip -d opt \
&& unzip weasyprint-layer-python${RUNTIME}-no-fonts.zip -d opt \
&& cd opt && zip -r9 ../weasyprint-layer-python${RUNTIME}.zip .
build/fonts-layer.zip: fonts/layer_builder.sh | _build
${DOCKER_RUN} \
-v `pwd`/fonts:/out \
--entrypoint "/out/layer_builder.sh" \
-t public.ecr.aws/lambda/python:${RUNTIME}
mv -f ./fonts/layer.zip $@
build/ghostscript-layer.zip: ghostscript/layer_builder.sh | _build
${DOCKER_RUN} \
-v `pwd`/ghostscript:/out \
--entrypoint "/out/layer_builder.sh" \
-t public.ecr.aws/lambda/python:${RUNTIME}
mv -f ./ghostscript/layer.zip $@
stack.diff:
cd cdk-stacks && npm install && npm run build
cdk diff --app ./cdk-stacks/bin/app.js --stack PrintStack --parameters uploadBucketName=${BUCKET}
stack.deploy:
cd cdk-stacks && npm install && npm run build
cdk deploy --app ./cdk-stacks/bin/app.js --stack PrintStack --parameters uploadBucketName=${BUCKET}
test.start.container: build/weasyprint-layer-python$(RUNTIME).zip
${DOCKER_RUN} \
-e GDK_PIXBUF_MODULE_FILE="/opt/lib/loaders.cache" \
-e FONTCONFIG_PATH="/opt/fonts" \
-e XDG_DATA_DIRS="/opt/lib" \
-v `pwd`/weasyprint:/var/task \
-v `pwd`/build/opt:/opt \
-p 9000:8080 \
public.ecr.aws/lambda/python:${RUNTIME} \
lambda_function.lambda_handler
test.print.report:
which jq
curl --fail -s -S -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" \
-d '{"return": "base64", "filename": "${TEST_FILENAME}", "url": "https://kotify.github.io/cloud-print-utils/samples/report/"}' \
| tail -1 | jq .body | tr -d '"' | base64 -d > ${TEST_FILENAME}
@echo "Check ./${TEST_FILENAME}, eg.: xdg-open ${TEST_FILENAME}"
_build:
@mkdir -p build
clean:
rm -rf ./build