question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document limitations of using buildpacks to build a native image on ARM64 devices

See original GitHub issue

I use spring boot 3.0.0-RC2, with Java 17 and the newest Docker version 4.14.0. Tested it on an M1 Max. I init a complete plain/new spring project with the Jetbrains IntelliJ project init tool. Then I try to run gradle bootBuildImage but it gets stuck at this point:

    [creator]     ================================================================================
    [creator]     GraalVM Native Image: Generating '/layers/paketo-buildpacks_native-image/native-image/com.example.demo1rtert.Demo1rtertApplicationKt' (static executable)...
    [creator]     ================================================================================
    [creator]     [1/7] Initializing...                                           (39.4s @ 0.19GB)
    [creator]      Version info: 'GraalVM 22.3.0 Java 17 CE'
    [creator]      Java version info: '17.0.5+8-LTS'
    [creator]      C compiler: gcc (linux, x86_64, 7.5.0)
    [creator]      Garbage collector: Serial GC
    [creator]      1 user-specific feature(s)
    [creator]      - org.springframework.aot.nativex.feature.PreComputeFieldFeature
    [creator]     Field org.springframework.core.NativeDetector#imageCode set to true at build time
    [creator]     Field org.springframework.core.KotlinDetector#kotlinPresent set to true at build time
    [creator]     Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to true at build time
    [creator]     Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time

It is there for hours.

build.gradle.kts:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "3.0.0-RC2"
    id("io.spring.dependency-management") version "1.1.0"
    id("org.graalvm.buildtools.native") version "0.9.17"
    kotlin("jvm") version "1.7.20"
    kotlin("plugin.spring") version "1.7.20"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
    mavenCentral()
    maven { url = uri("https://repo.spring.io/milestone") }
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("io.projectreactor:reactor-test")
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "17"
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

Bildschirm­foto 2022-11-13 um 18 16 54

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Nov 14, 2022

Given that this is a limitation that Spring Boot cannot control, we should probably mention it on the wiki.

1reaction
dr-emecommented, Nov 15, 2022

The issue is with the paketo builder, which uses an AMD64 image which runs with QEMU on ARM systems like Apple Silicon, and performance is very poor.

While there is no official support for ARM64 just yet, there is a preliminary workaround by using the following experimental builder:

bootBuildImage {
  if (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentArchitecture().isArm()) {
    builder = 'dashaun/java-native-builder-arm64'
  }
}

Please note that the compiled image will be ARM64. More info about the experimental builder can be found here: https://github.com/dashaun/paketo-arm64

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add support for arm64 · Issue #51 · paketo-buildpacks/stacks
I build the image locally (I am on M1) with spring maven plugin, run it with docker run ... . It works. I...
Read more >
Native Image ARM64 Support - GraalVM
Unless explicitly noted within the limitations, all Native Image features should work on this architecture. Limitations #. Mostly all Native Image features are ......
Read more >
Using Cloud Native Buildpacks to Improve the Function Image ...
Take an in-depth look at the Cloud Native Buildpacks and how to use it to build images for Function Mesh.
Read more >
Spring Native documentation
This section gives you a practical overview of building a Spring Boot native application using Cloud Native Buildpacks.
Read more >
Aidan Delaney - Building Multi-Architecture… - LinkedIn
We ask how applications can be built on x86_64 and produce images for both x86_64 and ARM64? Are the necessary changes to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found