Skip to content

Commit 2159c08

Browse files
hackathonhackathon
authored andcommitted
pushing multiple layers
1 parent a0bda65 commit 2159c08

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

.github/workflows/multi-layer.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Lambda Layers
2+
3+
on:
4+
push:
5+
paths:
6+
- 'layers/**'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-publish-layers:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
S3_BUCKET: hackathon-lambda-ap-ai-cyberark
15+
PYTHON_VERSION: python3.12
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.12'
25+
26+
- name: Configure AWS credentials
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
30+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31+
aws-region: us-east-1
32+
33+
- name: Build and publish each layer
34+
run: |
35+
for dir in layers/*; do
36+
if [ -f "$dir/requirements.txt" ]; then
37+
LAYER_NAME=$(basename "$dir")
38+
echo "Building layer: $LAYER_NAME"
39+
40+
# Create target directory
41+
mkdir -p "$dir/python"
42+
43+
# Install Python packages
44+
pip install --upgrade --no-cache-dir -r "$dir/requirements.txt" -t "$dir/python"
45+
46+
# Clean up unnecessary files
47+
find "$dir/python" -type d -name "__pycache__" -exec rm -rf {} +
48+
find "$dir/python" -type d -name "tests" -exec rm -rf {} +
49+
find "$dir/python" -type f -name "*.pyc" -delete
50+
find "$dir/python" -type d -name "*.dist-info" -exec rm -rf {} +
51+
52+
# Zip the layer
53+
cd "$dir"
54+
zip -r "../$LAYER_NAME.zip" python > /dev/null
55+
cd ../..
56+
57+
# Upload to S3
58+
echo "Uploading $LAYER_NAME.zip to S3"
59+
aws s3 cp "$dir.zip" s3://$S3_BUCKET/layers/$LAYER_NAME.zip
60+
61+
# Publish to Lambda
62+
echo "Publishing Lambda layer: $LAYER_NAME"
63+
LAYER_ARN=$(aws lambda publish-layer-version \
64+
--layer-name "$LAYER_NAME" \
65+
--description "Layer for $LAYER_NAME" \
66+
--content S3Bucket=$S3_BUCKET,S3Key=layers/$LAYER_NAME.zip \
67+
--compatible-runtimes $PYTHON_VERSION \
68+
--query 'LayerVersionArn' --output text)
69+
70+
echo "Published $LAYER_NAME: $LAYER_ARN"
71+
fi
72+
done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
numpy
2+
pandas
3+
boto3
4+
python-docx
5+
fastapi[all]
6+
uvicorn[standard]
7+
pydantic
8+
python-dotenv
9+
requests_toolbelt
10+
sqlmodel
11+
psycopg2-binary==2.9.9
12+
mangum
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sentence-transformers
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
faiss-cpu
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scikit-learn

0 commit comments

Comments
 (0)