Thundra APM
Search…
Deployment Integrations
Setting up Java SDK as Lambda Container Image
Docker Image Integration

Step 1: Pull the Thundra base image via Docker CLI

1
docker pull thundraio/thundra-lambda-container-base-java8:LATEST
Copied!

Step 2: Configure Your Dockerfile

  • Add Thundra base image as parent
1
FROM thundraio/thundra-lambda-container-base-java8:LATEST
Copied!
  • (Optional) Add following line to your Dockerfile if you want use a different version of the Thundra agent instead of the one coming with the base image.
1
RUN /opt/thundra/thundra-version-updater.sh <version>
Copied!
The latest available version you can use to replace the <version> parameter
  • Make sure your function code is added to the task directory of your docker image and handler is set as the first argument of CMD
1
# your function code path
2
ARG FUNCTION_CODE_PATH="target/sample-app.jar"
3
4
# task directory
5
ARG TASK_DIR="/var/task"
6
7
# create task directory
8
RUN mkdir -p ${TASK_DIR}
9
10
# copy your function code to the task directory
11
COPY ${FUNCTION_CODE_PATH} ${TASK_DIR}
12
13
# Set the CMD to your handler
14
CMD ["io.thundra.container.sample.Handler"]
15
Copied!
You can set your handler also by parameter overriding outside of the Dockerfile or setting it as the value of Lamba environment variable THUNDRA_AGENT_LAMBDA_HANDLER
An example DockerFile:
1
FROM thundraio/thundra-lambda-container-base-java8:LATEST
2
3
RUN /opt/thundra/thundra-version-updater.sh 2.6.16
4
5
# your function code path
6
ARG FUNCTION_CODE_PATH="target/sample-app.jar"
7
8
# task directory
9
ARG TASK_DIR="/var/task"
10
11
# create task directory
12
RUN mkdir -p ${TASK_DIR}
13
14
# copy your function code to the task directory
15
COPY ${FUNCTION_CODE_PATH} ${TASK_DIR}
16
17
# Set the CMD to your handler
18
CMD ["io.thundra.container.sample.Handler"]
Copied!
Step 3: Build your container image
1
docker build -t <image-name>
Copied!
Step 4: Locally test your container image
  • Run your Lambda application locally
1
docker run -p 9000:8080 <image name>
Copied!
  • Invoke your local application
1
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'Step 3: Invoke Your Deployed Function
Copied!
You should see your function’s expected response as the output of this request. You can also see the invocation logs on the console you run the Docker image.
Step 4: Push the container image to ECR and deploy it to your Lambda function
Step 5: Configure your function
Set the THUNDRA_APIKEY environment variable to the API key value you got from the Thundra Console.
Copy link