'Running AWS Lambda / Spring Cloud Function in JDK 17 Docker image

I'm working on upgrading a Spring Cloud Functions lambda to run on JDK 17. Amazon does not provide base images for JDK 17, so instead of deploying a ZIP file I created a lambda that runs a Docker image. For running Java images my Dockerfile usually looks like this:

FROM amazoncorretto:17
VOLUME /tmp
COPY ./my-lambda-project/build/libs/my-lambda-project-1.0.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

which runs the jar created first using bootRun Gradle task. My Application.java class has the main method which looks like this:

public static void main(String[] args) {
    FunctionalSpringApplication.run(Application.class, args);
}

The main method uses FunctionalSpringApplication instead of SpringApplication.run (for faster start) and in the lambda config I specify the function handler to be org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest.

With the Dockerfile approach, I can use some combination of ENTRYPOINT or CMD. Is there a way to make this docker image when pushed to ECR run the lambda using JDK 17?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source