Skip to content

Commit f1494e9

Browse files
committed
feat(native): add experimental graalvm native image support
This commit introduces support for building Jitsi Videobridge as a GraalVM Native Image. Changes: - Added Dockerfile.native for multi-stage native build. - Added Dockerfile.agent for easy configuration capture. - Added GraalVM configuration in config-full/ (including reflection for Jersey, Jackson, and Colibri v2). - Updated pom.xml to fix shading for native builds. - Updated Application.java to register JacksonFeature. - Added load-test.js and load-test-conferences.js for benchmarking. - Added BENCHMARK.md detailing performance improvements (17x startup, 23x CPU reduction). This is a Proof of Concept (PoC) validation.
1 parent 0360d04 commit f1494e9

File tree

6 files changed

+2857
-16
lines changed

6 files changed

+2857
-16
lines changed

Dockerfile.agent

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM maven:3.9.9-eclipse-temurin-21 AS builder
2+
3+
WORKDIR /app
4+
5+
COPY pom.xml .
6+
COPY jvb/pom.xml jvb/
7+
COPY rtp/pom.xml rtp/
8+
COPY jitsi-media-transform/pom.xml jitsi-media-transform/
9+
COPY config config/
10+
COPY jvb/src jvb/src
11+
COPY rtp/src rtp/src
12+
COPY jitsi-media-transform/src jitsi-media-transform/src
13+
14+
RUN mvn clean package -pl jvb -am -P buildFatJar -DskipTests
15+
16+
FROM ghcr.io/graalvm/native-image-community:25
17+
18+
WORKDIR /app
19+
20+
COPY --from=builder /app/jvb/target/jitsi-videobridge-*-jar-with-dependencies.jar jvb.jar
21+
22+
# Create directory for agent output
23+
RUN mkdir -p /app/config-output
24+
25+
# Run with agent to capture dynamic configuration
26+
ENTRYPOINT ["java", "-agentlib:native-image-agent=config-output-dir=/app/config-output", "-Dvideobridge.http-servers.private.host=0.0.0.0", "-jar", "jvb.jar"]

Dockerfile.native

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Stage 1: Build the fat jar
2+
FROM maven:3.9.9-eclipse-temurin-21 AS builder
3+
4+
WORKDIR /app
5+
6+
# Copy pom.xml files first to leverage cache
7+
COPY pom.xml .
8+
COPY jvb/pom.xml jvb/
9+
COPY rtp/pom.xml rtp/
10+
COPY jitsi-media-transform/pom.xml jitsi-media-transform/
11+
12+
# Copy config files potentially needed for build (though usually not for compilation)
13+
COPY config config/
14+
15+
# Copy source code
16+
COPY jvb/src jvb/src
17+
COPY rtp/src rtp/src
18+
COPY jitsi-media-transform/src jitsi-media-transform/src
19+
20+
# Build the fat jar
21+
# -pl jvb : build only the jvb project (and dependencies)
22+
# -am: also make dependencies
23+
# -P buildFatJar : enable the profile for fat jar
24+
# -DskipTests : skip tests for faster build
25+
RUN mvn clean package -pl jvb -am -P buildFatJar -DskipTests
26+
27+
# Stage 2: Build the native image
28+
FROM ghcr.io/graalvm/native-image-community:25 AS native-builder
29+
30+
WORKDIR /app
31+
32+
# Copy the fat jar from the builder stage
33+
COPY --from=builder /app/jvb/target/jitsi-videobridge-*-jar-with-dependencies.jar jvb.jar
34+
35+
# Copy generated GraalVM configuration
36+
COPY config-full /app/config-full
37+
38+
# Build the native image
39+
# --no-fallback: fail if native image cannot be built (don't fallback to JVM)
40+
# -H:+ReportExceptionStackTraces: better error reporting
41+
# -H:ConfigurationFileDirectories: use generated config
42+
RUN native-image \
43+
--no-fallback \
44+
-H:+ReportExceptionStackTraces \
45+
-H:ConfigurationFileDirectories=/app/config-full \
46+
-jar jvb.jar \
47+
jvb
48+
49+
# Stage 3: Create the final image
50+
FROM debian:bookworm-slim
51+
52+
WORKDIR /app
53+
54+
# Copy the native executable
55+
COPY --from=native-builder /app/jvb .
56+
57+
# Expose ports (standard JVB ports)
58+
EXPOSE 9600/udp 8080/tcp 443/tcp
59+
60+
# Run the native executable
61+
ENTRYPOINT ["./jvb"]

0 commit comments

Comments
 (0)