Skip to content
This repository was archived by the owner on Oct 21, 2019. It is now read-only.

Commit 4710db8

Browse files
author
Darren Weber
committed
make rules to build and package a lambda layer in /opt
1 parent d2f65cf commit 4710db8

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.zip

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ ENV \
77
RUN yum makecache fast
88
RUN yum install -y automake16 libpng-devel nasm
99

10-
ENV PREFIX /var/task
10+
# labda runtime: /var/task
11+
# labda layer: /opt
12+
ARG prefix=/var/task
13+
ENV PREFIX=${prefix}
1114

1215
# versions of packages
1316
ENV \

Makefile

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,33 @@ test:
2727
docker run ${BUILD} bash -c "python --version | grep '${PY_VERSION}'"
2828

2929
push:
30-
#docker tag ${IMAGE} ${BUILD}
3130
docker push ${DOCKER_USERNAME}/${BUILD}
3231

33-
clean:
34-
docker stop amazonlinux
35-
docker rm amazonlinux
32+
container-clean:
33+
docker stop amazonlinux > /dev/null 2>&1 || true
34+
docker rm amazonlinux > /dev/null 2>&1 || true
35+
36+
# ---
37+
# lambda layer build and package using /opt
38+
39+
LAYER_BUILD = ${BUILD}-layer
40+
LAYER_PACKAGE := amazonlinux-${TAG}-layer.zip
41+
42+
lambda-layer-build:
43+
docker build -f Dockerfile -t ${LAYER_BUILD} --build-arg prefix=/opt .
44+
45+
lambda-layer-shell: lambda-layer-build container-clean
46+
docker run --name amazonlinux --volume $(shell pwd)/:/data --rm -it ${LAYER_BUILD} /bin/bash
47+
48+
lambda-layer-package: lambda-layer-build container-clean
49+
docker run --name amazonlinux -itd ${LAYER_BUILD} /bin/bash
50+
docker exec -it amazonlinux bash -c 'mkdir -p $${PREFIX}/python/lib/python${PY_VERSION}/site-packages'
51+
docker exec -it amazonlinux bash -c 'rsync -a /var/lang/lib/python${PY_VERSION}/site-packages/ $${PREFIX}/python/lib/python${PY_VERSION}/site-packages/'
52+
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip python'
53+
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip lib/*.so*'
54+
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip lib64/*.so*'
55+
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip bin'
56+
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 /tmp/package.zip share'
57+
docker cp amazonlinux:/tmp/package.zip ${LAYER_PACKAGE}
58+
docker stop amazonlinux && docker rm amazonlinux
59+

0 commit comments

Comments
 (0)