Squashed commit of the following:
commit 0d624137c2557c6eeb87020749e4977b821c2b5c Author: Adrien <adrien.cesaro@proton.me> Date: Thu Apr 9 11:55:22 2026 +0200 backend native image setup
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package com.aiteacher;
|
||||
|
||||
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
import com.aiteacher.config.NativeHintsConfig;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
@ImportRuntimeHints(NativeHintsConfig.class)
|
||||
public class AiTeacherApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.aiteacher.config;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
|
||||
/**
|
||||
* GraalVM native-image runtime hints for third-party libraries that use reflection
|
||||
* or classpath resource scanning not covered by Spring Boot's AOT processor.
|
||||
*
|
||||
* Registered via @ImportRuntimeHints on AiTeacherApplication.
|
||||
*/
|
||||
public class NativeHintsConfig implements RuntimeHintsRegistrar {
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
// PDFBox — font and encoding resources loaded via classpath scanning at runtime
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/afm/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/cmap/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/glyphlist/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/icc/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/ttf/*");
|
||||
hints.resources().registerPattern("org/apache/pdfbox/resources/version.properties");
|
||||
|
||||
// PDFBox — font encoding classes instantiated via reflection
|
||||
hints.reflection().registerType(
|
||||
org.apache.pdfbox.pdmodel.font.encoding.GlyphList.class,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS
|
||||
);
|
||||
hints.reflection().registerType(
|
||||
org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding.class,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS
|
||||
);
|
||||
hints.reflection().registerType(
|
||||
org.apache.pdfbox.pdmodel.font.encoding.MacRomanEncoding.class,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS
|
||||
);
|
||||
hints.reflection().registerType(
|
||||
org.apache.pdfbox.pdmodel.font.encoding.MacExpertEncoding.class,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS
|
||||
);
|
||||
hints.reflection().registerType(
|
||||
org.apache.pdfbox.pdmodel.font.encoding.StandardEncoding.class,
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS
|
||||
);
|
||||
|
||||
// JPA / Hibernate — array types used in entity mappings
|
||||
hints.reflection().registerType(java.util.UUID[].class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
|
||||
// JBoss Logging — message logger implementations generated by annotation processor.
|
||||
// JBoss Logging uses reflection to look up the generated *_$logger class by name.
|
||||
registerJBossLogger(hints, "org.hibernate.jpa.internal.JpaLogger_$logger");
|
||||
registerJBossLogger(hints, "org.hibernate.internal.CoreMessageLogger_$logger");
|
||||
registerJBossLogger(hints, "org.hibernate.internal.EntityManagerMessageLogger_$logger");
|
||||
|
||||
// AWS SDK v2 — HTTP client and SdkPojo serialization
|
||||
hints.resources().registerPattern("software/amazon/awssdk/global/handlers/execution.interceptors");
|
||||
hints.resources().registerPattern("software/amazon/awssdk/services/s3/execution.interceptors");
|
||||
hints.resources().registerPattern("codegen-resources/s3/*");
|
||||
hints.reflection().registerType(
|
||||
software.amazon.awssdk.services.s3.S3Client.class,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS
|
||||
);
|
||||
}
|
||||
|
||||
private void registerJBossLogger(RuntimeHints hints, String className) {
|
||||
hints.reflection().registerType(
|
||||
TypeReference.of(className),
|
||||
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_PUBLIC_METHODS
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ spring:
|
||||
index-type: HNSW
|
||||
initialize-schema: false
|
||||
openai:
|
||||
api-key: ${OPENAI_API_KEY}
|
||||
api-key: ${OPENAI_API_KEY:}
|
||||
chat:
|
||||
options:
|
||||
model: gpt-4o-mini
|
||||
@@ -62,8 +62,8 @@ app:
|
||||
endpoint: https://s3.immich-ad.ovh
|
||||
region: garage
|
||||
bucket: ${S3_BUCKET:aiteacher}
|
||||
access-key-id: ${S3_ACCESS_KEY_ID}
|
||||
secret-access-key: ${S3_SECRET_ACCESS_KEY}
|
||||
access-key-id: ${S3_ACCESS_KEY_ID:}
|
||||
secret-access-key: ${S3_SECRET_ACCESS_KEY:}
|
||||
min-image-size-px: 100
|
||||
embedding:
|
||||
batch-size: 20
|
||||
|
||||
Reference in New Issue
Block a user