Skip to content

Commit

Permalink
Add graalvm java23
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrethor committed Oct 31, 2024
1 parent f9a31e0 commit ad88d4a
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@
"image": {
"baseImage": "public.ecr.aws/lambda/provided:al2023"
}
},
{
"displayName": "graalvm java23 (prov.al2023)",
"runtime": "provided.al2023",
"handler": "com.xavierbouclet.OkHandler",
"path": "graalvm_java23_on_provided_al2023",
"architectures": ["x86_64", "arm64"],
"image": {
"baseImage": "public.ecr.aws/lambda/provided:al2023"
}
}
]
}
26 changes: 26 additions & 0 deletions s3-uploader/runtimes/graalvm_java23_on_provided_al2023/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:24.1.1.0-Final-java23 AS builder
RUN curl https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz --output apache-maven-3.9.9-bin.tar.gz
RUN tar xzf apache-maven-3.9.9-bin.tar.gz
COPY src ./src
COPY pom.xml .
RUN ./apache-maven-3.9.9/bin/mvn package -Pnative

# strip the binary
FROM ubuntu AS stripper
RUN apt-get update -y
RUN apt-get install -y binutils
COPY --from=builder /project/target/graalvm-java23 /tmp
RUN strip /tmp/graalvm-java23

# zip the extension
FROM ubuntu:latest AS compresser
RUN apt-get update
RUN apt-get install -y zip
RUN mkdir /package
WORKDIR /package
COPY --from=stripper /tmp/graalvm-java23 /package/bootstrap
RUN zip -j code.zip /package/bootstrap

FROM scratch
COPY --from=compresser /package/code.zip /
ENTRYPOINT ["/code.zip"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DIR_NAME="./runtimes/$1"
ARCH=$2

rm ${DIR_NAME}/code_${ARCH}.zip 2> /dev/null

docker build ${DIR_NAME} -t maxday/graalvm-java21_on_provided_al2
dockerId=$(docker create maxday/graalvm-java21_on_provided_al2)
docker cp $dockerId:/code.zip ${DIR_NAME}/code_${ARCH}.zip
128 changes: 128 additions & 0 deletions s3-uploader/runtimes/graalvm_java23_on_provided_al2023/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.xavierbouclet</groupId>
<artifactId>graalvm-java23</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>23</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.shade.plugin.version>3.2.1</maven.shade.plugin.version>
<maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<aws.java.sdk.version>2.25.5</aws.java.sdk.version>
<slf4j.version>1.7.28</slf4j.version>
<graalvm.version>24.1.1</graalvm.version>
<graalvm.native.maven.plugin.version>0.10.3</graalvm.native.maven.plugin.version>
<junit5.version>5.10.2</junit5.version>
<maven.compiler.plugin.version>3.13.0</maven.compiler.plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>${aws.java.sdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
<exclusions>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
</exclusion>
<exclusion>
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
</exclusion>
</exclusions>
</dependency>


<dependency>
<groupId>com.formkiq</groupId>
<artifactId>lambda-runtime-graalvm</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${graalvm.native.maven.plugin.version}</version>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>graalvm-java23</imageName>
<mainClass>com.formkiq.lambda.runtime.graalvm.LambdaRuntime</mainClass>
<buildArgs combine.children="append">
<!-- BouncyCastleAlpn issue tracked in https://github.com/netty/netty/issues/11369 -->
<buildArgs>
--verbose
--initialize-at-build-time=org.slf4j
--initialize-at-run-time=io.netty.handler.ssl.BouncyCastleAlpnSslUtils
--enable-url-protocols=http
-H:ReflectionConfigurationFiles=${project.basedir}/src/main/resources/reflect.json
</buildArgs>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.xavierbouclet;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class OkHandler implements RequestHandler<Object, String>{

static {
System.setProperty("software.amazon.awssdk.http.service.impl",
"software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService");
}

@Override
public String handleRequest(Object s, Context context) {
return "ok";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"name": "com.xavierbouclet.OkHandler",
"allDeclaredConstructors": true,
"allPublicConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true
}
]

0 comments on commit ad88d4a

Please sign in to comment.