-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.native
More file actions
51 lines (39 loc) · 1.67 KB
/
Dockerfile.native
File metadata and controls
51 lines (39 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM --platform=$BUILDPLATFORM ghcr.io/graalvm/native-image-community:25 AS builder
# Maven wrapper needs unzip to extract Maven distribution
RUN microdnf install -y unzip freetype fontconfig
WORKDIR /app
# Copy Maven wrapper and POM first for layer caching
COPY mvnw pom.xml ./
COPY .mvn .mvn
RUN chmod +x mvnw && ./mvnw dependency:go-offline --no-transfer-progress -q 2>/dev/null || true
# Copy source code
COPY src src
COPY comparison/svg comparison/svg
# Build shaded CLI JAR (jni-config.json is embedded in the JAR via META-INF)
RUN ./mvnw -DskipTests package --no-transfer-progress
# Collect additional native-image metadata with tracing agent (all SVGs)
RUN mkdir -p native-config && \
for svg in comparison/svg/*.svg; do \
java -Djava.awt.headless=true \
-agentlib:native-image-agent=config-merge-dir=native-config \
-jar target/*-cli.jar "$svg" -o "/tmp/$(basename "$svg" .svg).png" || true; \
done && \
echo "=== Collected metadata ===" && ls -la native-config/
# Build native image
# jni-config.json from META-INF is auto-discovered; tracing agent adds AWT/Java2D reflection
RUN native-image \
-Djava.awt.headless=true \
-H:ConfigurationFileDirectories=native-config \
-o jairosvg \
-jar target/*-cli.jar && \
mkdir -p /output && cp jairosvg /output/ && \
cp lib*.so /output/ 2>/dev/null || true
# --- Runtime stage ---
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y --no-install-recommends \
fontconfig fonts-dejavu-core libfreetype6 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /output/ /app/
COPY --from=builder /app/comparison/svg comparison/svg
ENTRYPOINT ["/app/jairosvg"]