41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# build-prisma-layer.sh
|
|
# Script to rebuild the Prisma layer for Lambda deployment
|
|
# Usage: ./build-prisma-layer.sh
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
LAYER_PATH="$SCRIPT_DIR/layers/prisma/nodejs"
|
|
|
|
echo "🔄 Building Prisma layer for Lambda..."
|
|
|
|
# Step 1: Regenerate Prisma client
|
|
echo "📦 Regenerating Prisma client..."
|
|
cd "$SCRIPT_DIR"
|
|
npx prisma generate
|
|
|
|
# Step 2: Clean layer node_modules
|
|
echo "🧹 Cleaning layer node_modules..."
|
|
rm -rf "$LAYER_PATH/node_modules"
|
|
|
|
# Step 3: Install layer dependencies
|
|
echo "📥 Installing layer dependencies..."
|
|
cd "$LAYER_PATH"
|
|
npm install --production
|
|
|
|
# Step 4: Copy generated Prisma client to layer
|
|
echo "📋 Copying generated Prisma client to layer..."
|
|
mkdir -p "$LAYER_PATH/node_modules/.prisma"
|
|
cp -r "$SCRIPT_DIR/node_modules/.prisma/client" "$LAYER_PATH/node_modules/.prisma/client"
|
|
|
|
# Step 5: Calculate layer size
|
|
LAYER_SIZE=$(du -sh "$LAYER_PATH" | cut -f1)
|
|
echo "✅ Layer built successfully!"
|
|
echo "📊 Layer size: $LAYER_SIZE"
|
|
|
|
# List contents
|
|
echo ""
|
|
echo "📁 Layer contents:"
|
|
ls -d "$LAYER_PATH/node_modules"/*/ 2>/dev/null | xargs -n 1 basename | sed 's/^/ - /'
|