Skip to content

Commit 9068155

Browse files
committed
Rewrite lambda build script
1 parent e1c7769 commit 9068155

File tree

3 files changed

+265
-236
lines changed

3 files changed

+265
-236
lines changed

Dockerfile

-49
This file was deleted.

README.md

+3-54
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,9 @@
1-
[![Docker Hub Build Status](https://img.shields.io/docker/cloud/build/mageops/aws-lambda-build?label=Docker+Image+Build)](https://hub.docker.com/r/mageops/aws-lambda-build/builds)
21
# MageOps Docker Container for building AWS Lambda Docker Packages
3-
4-
Simple, unopinionated, amamazonlinux-base contaiener that builds
5-
deploy packages suitable for running lambdas which have custom dependencies.
6-
7-
PS It's on [Docker Hub](https://hub.docker.com/r/mageops/aws-lambda-build).
8-
9-
### Build container
10-
11-
#### Build using defaults (w/nodejs12.x)
12-
13-
```bash
14-
docker build . -t mageops/aws-lambda-build
15-
```
16-
17-
#### Build w/nodejs10.x (still required for Cloudfront Edge Lambdas)
18-
19-
```bash
20-
docker build . -t mageops/aws-lambda-build:nodejs10.x --build-arg LAMBDA_NODEJS_RELEASE=10.x
21-
```
2+
Build script to create AWS Lambda packages for Python and NodeJS 10.x
223

234
### Build lambda
245

256
```bash
26-
docker run --rm -v "$(pwd):/var/app" mageops/aws-lambda-build python2 name-of-your-lambda
27-
docker run --rm -v "$(pwd):/var/app" mageops/aws-lambda-build python3 name-of-your-lambda
28-
docker run --rm -v "$(pwd):/var/app" mageops/aws-lambda-build nodejs name-of-your-lambda
29-
docker run --rm -v "$(pwd):/var/app" mageops/aws-lambda-build nodejs-yarn name-of-your-lambda
30-
```
31-
32-
### Custom build hook scripts
33-
34-
In case you need to perform any custom commands pre/post the dependency installation (core build step)
35-
just create executable shell scripts (make sure they have executable permission!) and place them in:
36-
- `.lambda-build-hook/pre-build.sh`
37-
- `.lambda-build-hook/post-build.sh`
38-
39-
### Installing custom shared libraries
40-
41-
Sometimes the core system images lacks certain libraries. Fortunately the default
42-
`LD_LIBRARY_PATH` in lambda runtime env contains `$LAMBDA_TASK_ROOT/lib` path
43-
so shared libs placed in `lib` subdirectory are loaded automatically when needed.
44-
45-
_*Note that system-wide library dirs are prioritized* on the library path thus
46-
it's not possible to override system libraries this way, only add missing ones.
47-
You can force usage of your custom libraries by overriding the `LD_LIBRARY_PATH`
48-
environment variable in lambda configuration though._
49-
50-
The best way to install shared libs is to copy them in post-build hook script,
51-
you can also make sure appropriate libs are installed via `yum`.
52-
53-
Example `.lambda-build-hook/post-build.sh` script which installs `libjpeg-turbo`:
54-
55-
```
56-
#!/usr/bin/env bash
57-
yum -y install libjpeg-turbo
58-
mkdir -pv "${LAMBDA_SHARED_LIB_DIR}"
59-
cp -v /usr/lib64/libjpeg.so.* "${LAMBDA_SHARED_LIB_DIR}"
7+
./build.sh --lang python --python-version 3.11 -p package-name ./package-dir
8+
./build.sh --lang nodejs --nodejs-version 10.x -p package-name ./package-dir
609
```

0 commit comments

Comments
 (0)