Last active
June 1, 2023 21:50
-
-
Save sladg/2532e992f3d2c263e56f867cbf6546a4 to your computer and use it in GitHub Desktop.
Generate Prisma layer for Lambda functions in AWS. Tested on Linux and MacOS with Postgres as target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 - generate node_modules layer, | |
# 2 - reference layer in CDK code, | |
# 3 - profit. | |
#!/bin/sh | |
set -e | |
LAMBDA_FOLDER=nodejs | |
PRISMA_CLI_BINARY_TARGETS=rhel-openssl-1.0.x | |
PRISMA_CLI_QUERY_ENGINE_TYPE=binary | |
PRISMA_CLIENT_ENGINE_TYPE=binary | |
rm -r dist || true | |
mkdir -p dist | |
npm install \ | |
--arch=x64 \ | |
--platform=linux \ | |
--target=16.15 \ | |
--libc=glibc \ | |
--prefix=$LAMBDA_FOLDER \ | |
--ignore-scripts=false \ | |
--verbose \ | |
prisma @prisma/client pg | |
cp -r ../../node_modules/.prisma $LAMBDA_FOLDER/node_modules | |
# We need to delete redudaunt files to reduce the size of the layer | |
find $LAMBDA_FOLDER/node_modules -maxdepth 5 -name "*engine*darwin*" -delete | |
zip -q -r dist/prisma-layer.zip $LAMBDA_FOLDER | |
rm -rf $LAMBDA_FOLDER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment