Skip to content

Commit 20ddb1e

Browse files
authored
fix lambda build script (#51)
* fix lambda build script * update the docs
1 parent 4c2a8f2 commit 20ddb1e

File tree

9 files changed

+41
-22
lines changed

9 files changed

+41
-22
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- run:
3030
name: Build lambdas
3131
command:
32-
bin/build_lambdas.sh
32+
deployment/build-lambdas.sh
3333

3434
- run:
3535
name: Deploy infrastructure

.github/workflows/integration-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
- name: Build lambdas
6464
run: |
65-
bin/build_lambdas.sh
65+
deployment/build-lambdas.sh
6666
6767
- name: Deploy infrastructure
6868
run: |
@@ -136,7 +136,7 @@ jobs:
136136

137137
- name: Build lambdas
138138
run: |
139-
bin/build_lambdas.sh
139+
deployment/build-lambdas.sh
140140
141141
- name: Deploy infrastructure
142142
run: |

.github/workflows/preview_create.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141
preview-cmd: |
4242
# Add your custom deployment commands here.
4343
# Below is an example for the Image resizer application.
44-
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
44+
deployment/build-lambdas.sh && deployment/awslocal/deploy.sh

.github/workflows/test_cloudpods.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Deploy Infrastructure (Example)
5050
run: |
51-
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
51+
deployment/build-lambdas.sh && deployment/awslocal/deploy.sh
5252
5353
- name: Export LocalStack State File
5454
id: export_state

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ deploy:
5757
- .github/*
5858
- when: always
5959
script:
60-
- ./bin/build_lambdas.sh
60+
- ./deployment/build-lambdas.sh
6161
- ./deployment/awslocal/deploy.sh
6262
- mkdir -p /usr/lib/localstack
6363
- localstack state export ls-state-pod.zip

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ install:
2828
## Build the Lambda functions
2929
build-lambdas:
3030
@echo "Building the Lambda functions..."
31-
bash -c "source venv/bin/activate && bin/build_lambdas.sh"
31+
bash -c "source venv/bin/activate && deployment/build-lambdas.sh"
3232
@echo "Lambda functions built successfully."
3333

3434
## Deploy the application locally using `awslocal`, a wrapper for the AWS CLI

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,16 @@ localstack auth set-token <your-auth-token>
7171
localstack start
7272
```
7373

74+
Before deploying the sample application, you need to build the Lambda functions. Run the following command:
75+
76+
```shell
77+
deployment/build-lambdas.sh
78+
```
79+
7480
To deploy the sample application, run the following command:
7581

7682
```shell
77-
bin/deploy.sh
83+
deployment/awslocal/deploy.sh
7884
```
7985

8086
The output will show the Lambda function URLs that you can use in the web application:

buildspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ phases:
2525
- localstack start -d
2626
pre_build:
2727
commands:
28-
- bin/build_lambdas.sh
28+
- deployment/build-lambdas.sh
2929
- deployment/awslocal/deploy.sh
3030
build:
3131
commands:

deployment/build-lambdas.sh

100644100755
Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
#!/bin/bash
22

3-
BASE_DIR="lambdas"
4-
LAMBDA_DIRS=("presign" "list" "resize")
5-
6-
for dir in "${LAMBDA_DIRS[@]}"; do
7-
LAMBDA_PATH="$BASE_DIR/$dir"
8-
echo "Zipping Lambda function in $LAMBDA_PATH..."
9-
if [ -d "$LAMBDA_PATH" ]; then
10-
zip -r "$LAMBDA_PATH/lambda.zip" "$LAMBDA_PATH"/*
11-
else
12-
echo "Directory $LAMBDA_PATH not found!"
13-
exit 1
14-
fi
15-
done
3+
(cd lambdas/presign; rm -f lambda.zip; zip lambda.zip handler.py)
4+
5+
(cd lambdas/list; rm -f lambda.zip; zip lambda.zip handler.py)
6+
7+
os=$(uname -s)
8+
if [ "$os" == "Darwin" ]; then
9+
(
10+
cd lambdas/resize
11+
rm -rf libs lambda.zip
12+
docker run --platform linux/x86_64 --rm -v "$PWD":/var/task "public.ecr.aws/sam/build-python3.11" /bin/sh -c "pip3 install -r requirements.txt -t libs; exit"
13+
14+
cd libs && zip -r ../lambda.zip . && cd ..
15+
zip lambda.zip handler.py
16+
rm -rf libs
17+
)
18+
else
19+
(
20+
cd lambdas/resize
21+
rm -rf package lambda.zip
22+
mkdir package
23+
pip3 install -r requirements.txt --platform manylinux2014_x86_64 --only-binary=:all: -t package
24+
zip lambda.zip handler.py
25+
cd package
26+
zip -r ../lambda.zip *;
27+
)
28+
fi

0 commit comments

Comments
 (0)