Skip to content

Commit e2c5cf4

Browse files
authored
Update README for ENTRYPOINT (#41)
1 parent 54e07e1 commit e2c5cf4

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

README.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## AWS Lambda Ruby Runtime Interface Client
22

3-
We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that implement the Lambda
4-
[Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), allowing you to seamlessly extend your preferred
5-
base images to be Lambda compatible.
6-
The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to receive requests from and send requests to the Lambda service.
3+
We have open-sourced a set of software packages, Runtime Interface Clients (RIC), that implements the Lambda
4+
[Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), allowing you to seamlessly extend
5+
your preferred base images to be Lambda compatible.
6+
The Lambda Runtime Interface Client is a lightweight interface that allows your runtime to
7+
receive requests from and send requests to the Lambda service.
78

89
The Lambda Ruby Runtime Interface Client is vended through [rubygems](https://rubygems.org/gems/aws_lambda_ric).
910
You can include this package in your preferred base image to make that base image Lambda compatible.
1011

1112
## Requirements
12-
The Ruby Runtime Interface Client package currently supports Ruby versions:
13-
- 3.2 and 3.3
13+
The Ruby Runtime Interface Client package currently supports ruby 3.0 and above.
1414

1515
## Usage
1616

@@ -37,17 +37,9 @@ Or install it manually as:
3737

3838
$ gem install aws_lambda_ric
3939

40-
41-
Next step would be to copy your Lambda function code into the image's working directory.
42-
```dockerfile
43-
# Copy function code
44-
RUN mkdir -p ${FUNCTION_DIR}
45-
COPY app.rb ${FUNCTION_DIR}
46-
47-
WORKDIR ${FUNCTION_DIR}
48-
```
49-
50-
The next step would be to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and then set the `CMD` argument to specify the desired handler.
40+
The next step would be to copy your Lambda function code into the image's working directory.
41+
You will need to set the `ENTRYPOINT` property of the Docker image to invoke the Runtime Interface Client and
42+
then set the `CMD` argument to specify the desired handler.
5143

5244
Example Dockerfile:
5345
```dockerfile
@@ -84,7 +76,18 @@ ENTRYPOINT ["/usr/local/bin/aws_lambda_ric"]
8476
CMD ["app.App::Handler.process"]
8577
```
8678

87-
Example Ruby handler `app.rb`:
79+
Note that the `ENTRYPOINT` may differ based on the base image used. You can find the correct path by running an
80+
interactive shell in the container and checking the installed location of the gem.
81+
82+
```shell script
83+
docker run -it --rm amazonlinux:latest bash
84+
yum install -y which ruby
85+
gem install aws_lambda_ric
86+
which aws_lambda_ric
87+
```
88+
89+
Finally, create a Ruby handler. This is an example `app.rb`:
90+
8891
```ruby
8992
module App
9093
class Handler
@@ -97,7 +100,10 @@ end
97100

98101
### Local Testing
99102

100-
To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server, Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests. You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function. Then when you run the image function, you set the entrypoint to be the emulator.
103+
To make it easy to locally test Lambda functions packaged as container images we open-sourced a lightweight web-server,
104+
Lambda Runtime Interface Emulator (RIE), which allows your function packaged as a container image to accept HTTP requests.
105+
You can install the [AWS Lambda Runtime Interface Emulator](https://github.com/aws/aws-lambda-runtime-interface-emulator) on your local machine to test your function.
106+
Thenm when you run the image function, you set the entrypoint to be the emulator.
101107

102108
*To install the emulator and test your Lambda function*
103109

@@ -108,7 +114,8 @@ mkdir -p ~/.aws-lambda-rie && \
108114
curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \
109115
chmod +x ~/.aws-lambda-rie/aws-lambda-rie
110116
```
111-
2) Run your Lambda image function using the docker run command.
117+
118+
1) Run your Lambda image function using the docker run command.
112119

113120
```shell script
114121
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
@@ -119,7 +126,7 @@ docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
119126

120127
This runs the image as a container and starts up an endpoint locally at `http://localhost:9000/2015-03-31/functions/function/invocations`.
121128

122-
3) Post an event to the following endpoint using a curl command:
129+
1) Post an event to the following endpoint using a curl command:
123130

124131
```shell script
125132
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'

0 commit comments

Comments
 (0)