Dockerfile to statically compile LibRSVG for AWS Lambda instances powered by Amazon Linux 2.x. Pre-built layers are available for both x86_64 and arm64 Lambdas.
The rsvg
binary will be in /opt/bin/rsvg-convert
after linking the layer to a Lambda function.
The Lambda Layer ZIPs can be found in Releases.
In order to use it, download one of the zips, then deploy them as follows:
aws lambda publish-layer-version \
--layer-name rsvg \
--description "Librsvg layer for x86_64" \
--license-info "MIT License" \
--zip-file fileb://librsvg-lambda-layer.x86_64.zip \
--compatible-architectures x86_64
aws lambda publish-layer-version \
--layer-name rsvg-arm64 \
--description "Librsvg layer for arm64" \
--license-info "MIT License" \
--zip-file fileb://librsvg-lambda-layer.aarch64.zip \
--compatible-architectures arm64
- Docker
- AWS command line utilities (just for deployment)
- Clone the repository
git clone github.com/bubblydoo/librsvg-lambda-layer
cd librsvg-lambda-layer
- Start Docker services and build image (this might take a while)
docker build . --target librsvg-layer -t amazon-linux-librsvg-layer
# docker build . --target librsvg -t amazon-linux-librsvg
# docker build . --target builder -t amazon-linux-librsvg-builder
or for a multiplatform image:
docker buildx create --use # if you didn't make a builder yet
docker buildx build . --platform linux/amd64,linux/arm64 --target librsvg-layer -t amazon-linux-librsvg-layer
- Copy zip to ./dist
docker run --platform linux/amd64 -v "$PWD/dist":/dist amazon-linux-librsvg-layer
docker run --platform linux/arm64 -v "$PWD/dist":/dist amazon-linux-librsvg-layer
- Inspect layer content
unzip -l dist/librsvg-layer.x86_64.zip
unzip -l dist/librsvg-layer.aarch64.zip
- Deploy to AWS
aws lambda publish-layer-version \
--layer-name rsvg \
--description "Librsvg layer for x86_64" \
--license-info "MIT License" \
--zip-file fileb://dist/librsvg-layer.x86_64.zip \
--compatible-architectures x86_64
aws lambda publish-layer-version \
--layer-name rsvg-arm64 \
--description "Librsvg layer for arm64" \
--license-info "MIT License" \
--zip-file fileb://dist/librsvg-layer.aarch64.zip \
--compatible-architectures arm64
- Images with
xlink:href="file://
do not load properly. You can inline the files as adata://
uri as a workaround. - Only jpeg and png builtin loaders are enabled (for usage with
data://
), but more can be enabled inDockerfile
For more information, check out:
Hans Otto Wirtz https://github.com/hansottowirtz Gojko Adzic https://gojko.net
- These scripts: MIT
- Rsvg: https://github.com/GNOME/librsvg/blob/master/COPYING
- Contained libraries all have separate licenses, check the respective web sites for more information