Skip to content

Commit 70a2045

Browse files
Implement local RIC running
2 parents 018c29c + 7d3ab3d commit 70a2045

File tree

5 files changed

+68
-30
lines changed

5 files changed

+68
-30
lines changed

Dockerfile.rie

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM public.ecr.aws/lambda/ruby:3.3
2+
3+
# Copy source code and build gem in container
4+
COPY . ${LAMBDA_TASK_ROOT}/
5+
WORKDIR ${LAMBDA_TASK_ROOT}
6+
7+
# Uninstall any existing RIC gem for a clean start
8+
RUN gem uninstall -x aws_lambda_ric || true
9+
10+
# Build and install the RIC gem
11+
RUN gem install bundler && \
12+
bundle install && \
13+
rake build && \
14+
gem install pkg/aws_lambda_ric-*.gem
15+
16+
# Copy handler to task root
17+
COPY test/integration/test-handlers/echo/app.rb ${LAMBDA_TASK_ROOT}/
18+
19+
CMD ["app.App::Handler.process"]

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ test-integ: setup-codebuild-agent
2727
build:
2828
rake build
2929

30+
.PHONY: run-local-ric
31+
run-local-ric:
32+
scripts/run-local-ric.sh
33+
3034
.PHONY: pr
3135
pr: init test-unit test-smoke
3236

@@ -42,6 +46,7 @@ TARGETS
4246
test-integ Run Integration tests.
4347
test-unit Run Unit Tests.
4448
test-smoke Run Sanity/Smoke tests.
49+
run-local-ric Run local RIC changes with Runtime Interface Emulator.
4550
pr Perform all checks before submitting a Pull Request.
4651

4752
endef

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ This command invokes the function running in the container image and returns a r
136136

137137
*Alternately, you can also include RIE as a part of your base image. See the AWS documentation on how to [Build RIE into your base image](https://docs.aws.amazon.com/lambda/latest/dg/images-test.html#images-test-alternative).*
138138

139+
### Automated Local Testing
140+
141+
For a simple approach to run your local RIC changes, use the one-command setup:
142+
143+
```shell script
144+
make run-local-ric
145+
```
146+
147+
This command will:
148+
1. Build a Docker image with your local RIC code
149+
2. Compile the gem inside the Linux container (avoiding OS compatibility issues)
150+
3. Start the Lambda Runtime Interface Emulator on port 9000
151+
4. Run a test Lambda function using your RIC
152+
153+
Once running, invoke the function from another terminal:
154+
155+
```shell script
156+
curl -X POST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
157+
```
158+
159+
Modify the test handler in `test/integration/test-handlers/echo/app.rb` to test different scenarios.
160+
139161
## Development
140162

141163
### Building the package

scripts/run-local-ric.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
6+
7+
8+
IMAGE_TAG="ruby-ric-rie-test"
9+
HANDLER="${1:-app.App::Handler.process}"
10+
11+
echo "Starting RIE test setup for Ruby..."
12+
13+
echo "Building test Docker image..."
14+
docker build -t "$IMAGE_TAG" -f "$PROJECT_ROOT/Dockerfile.rie" "$PROJECT_ROOT"
15+
16+
echo "Starting test container on port 9000..."
17+
echo ""
18+
echo "In another terminal, invoke with:"
19+
echo "curl -s -X POST -H 'Content-Type: application/json' \"http://localhost:9000/2015-03-31/functions/function/invocations\" -d '{\"message\":\"test\"}'"
20+
echo ""
21+
22+
exec docker run -it -p 9000:8080 -e _HANDLER="$HANDLER" "$IMAGE_TAG"

test/integration/docker-compose.template.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)