Coder Social home page Coder Social logo

dashaun / paketo-arm64 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dmikusa/paketo-arm64

84.0 3.0 7.0 140 KB

Tools and instructions for creating a Paketo builder for ARM64

Home Page: https://youtu.be/BuqNJl4QrUw

Shell 100.00%
cloud-native-buildpacks spring spring-boot arm64 graalvm

paketo-arm64's Introduction

Forks Stargazers Issues

Paketo Buildpacks Multi-Architecture Builder

dashaun/builder-arm

This repo is used to generate:

  • dashaun/builder-arm a modified version of paketobuildpacks/builder that works with ARM64 architectures like M1, M2, Raspberry Pi, and Rock Pi
  • dashaun/builder:tiny a manifest delivering dashaun/builder-arm:tiny for ARM64 and paketobuildpacks/builder:tiny for AMD64
  • dashaun/builder:base a manifest delivering dashaun/builder-arm:base for ARM64 and paketobuildpacks/builder:base for AMD64

The dashaun/builder-arm:base just changes the stack, it does not include the all of the 'base' buildpacks

Quick Start Maven

Create a Spring Boot project:

curl https://start.spring.io/starter.tgz -d dependencies=web,actuator,native -d javaVersion=21 -d bootVersion=3.2.4 -d type=maven-project | tar -xzf -

In the pom.xml replace this:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

with this:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <image>
                    <builder>dashaun/builder:tiny</builder>
                </image>
            </configuration>
        </plugin>
    </plugins>
</build>

Create OCI images just like you would with paketobuildpacks/builder:tiny:

./mvnw -Pnative spring-boot:build-image

Quick Start Gradle

Create a Spring Boot project:

curl https://start.spring.io/starter.tgz -d dependencies=web,actuator,native -d javaVersion=21 -d bootVersion=3.1.4 -d type=gradle-project | tar -xzf -

In the build.gradle add this:

tasks.named("bootBuildImage") {
    builder = "dashaun/builder:tiny"
    environment = ["BP_NATIVE_IMAGE" : "true"]
}

Create OCI images just like you would with paketobuildpacks/builder:tiny:

./gradlew bootBuildImage

Quick Start Validation

Test the image by running it with docker:

docker run --rm -d -p 8080:8080 demo:0.0.1-SNAPSHOT

Validate the image:

http :8080/actuator/health
HTTP/1.1 200 
Connection: keep-alive
Content-Type: application/vnd.spring-boot.actuator.v3+json
Date: Sat, 27 Apr 2023 05:04:36 GMT
Keep-Alive: timeout=60
Transfer-Encoding: chunked

{
    "status": "UP"
}

Goals of this repository

  • Deliver a buildpack that can be used with Spring Boot 3 and GraalVM on ARM64 architecture
  • Deliver a buildpack that can be used the same way on ARM64 and AMD64
  • Help deliver ARM64 and multi-architecture support upstream to Paketo

Please use it and provide feedback! Pull requests are welcome!

GitHub Action Workflow & CirleCI Workflow

I'm no longer using self-hosted infrastructure! ARM64 workflows now use CircleCI!

See Also

Thank you

paketo-arm64's People

Contributors

dashaun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paketo-arm64's Issues

How do I build for nodejs and go

Hey Man, great work you have going here.

I have been tasked by my manager to use this and build builders for go and node.

How ever I am a bit confused on how to go about this.
I guess this only works for Java.

I'll be glad if I can get a feedback from you.
Thank you

Java 21?

Are you planning to support Java 21?

I have tried but it does not work.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]

Generate multiarch images with bootBuildImage

This is perhaps more of a Spring request rather than belonging here, but generally I'm curious on a way to solve this issue. Currently I'm using the builder-multiarch image with great success to generate Docker images for a Spring application in both x86_64 and arm64 architectures without issue:

    ./gradlew bootBuildImage \
        --imageName myapplication \
        --builder dashaun/builder-multiarch:latest

This doesn't quite work in a hybrid Kubernetes cluster scenario, however. What I'm doing right now is running the CI step on an ARM64 machine and tagging the deployments with nodeSelectors to make sure only the correct nodes are selected for execution (i.e. all x86_64 are off-limits and won't run the application workloads).

Ideally it'd be possible to build these images in a single pass (for both architectures) regardless of the underlying system, thus making it irrelevant which architecture a node has during execution. This would be akin to what docker buildx (https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/) or the manifest patching technique currently used in this project accomplish. As far as I've checked bootBuildImage has no such option, however.

Is this a situation you've seen/solved in the past?

What's the reason to add 'environment = ["BP_NATIVE_IMAGE" : "true"]' in build.gradle?

I tried using this buildpack instead of the ordinary paketo one to enable building aarch64 images.

When I added the following line, it didn't work however:

    environment = ["BP_NATIVE_IMAGE" : "true"]

What's the reason this should be added?

This is the build.gradle config that works:

tasks.named('bootBuildImage') {
    environment["BP_JVM_VERSION"] = "21"

    // https://paketo.io/docs/howto/configuration/
    environment["BPE_SPRING_PROFILES_ACTIVE"] = "docker"

    // To enable aarch64 images
    builder = "dashaun/builder:tiny"
}

This one doesn't work (it builds but the image misbehaves when I start it):

tasks.named('bootBuildImage') {
    environment["BP_JVM_VERSION"] = "21"

    // https://paketo.io/docs/howto/configuration/
    environment["BPE_SPRING_PROFILES_ACTIVE"] = "docker"

    environment = ["BP_NATIVE_IMAGE" : "true"]

    // To enable aarch64 images
    builder = "dashaun/builder:tiny"
}

Can't use "live update" with Tilt (missing "tar")

Hey there 👋

Thanks for maintaining an ARM-based builder, it's awesome. Start times are 10x faster.

I'm trying to use this with Tilt and its live_update feature (using BP_LIVE_RELOAD_ENABLED), and it blows up because the run image is missing tar:

LiveUpdate "authserver:springone_authserver" UpdateFailed: Updating pod authserver-7698bf6b69-rrsr4: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "6bbfa2086e6ec9baecb70000aa6e2fa3c46f1db5b6b8f9e5307eee61e082df04": OCI runtime exec failed: exec failed: unable to start container process: exec: "tar": executable file not found in $PATH: unknown
This usually means that Tilt could not exec `tar`.
Please check that the container image includes `tar` in $PATH.
Some minimal images, such as those that are built `FROM scratch`, will not work with Live Update by default.
See https://github.com/tilt-dev/tilt/issues/4303 for details.

Is there a way to squeeze tar in the run image? Or would this require a non "tiny" builder?

Edit:
We seem to need both tar and rm in the image, so maybe the builder need to use the "non-tiny" stack 🤔

Problem with Spring Boot 3.0.2 in maven native build

I tried to run the example exactly like you documented here in the README.md.

I tried
dashaun/builder-multiarch:tiny
dashaun/builder-arm:tiny
dashaun/builder:tiny

None is working in my MAC m1.

This is the error I get to run the build.

[INFO] [creator] ================================================================================ [INFO] [creator] GraalVM Native Image: Generating '/layers/paketo-buildpacks_native-image/native-image/com.example.demo.DemoApplication' (static executable)... [INFO] [creator] ================================================================================ [INFO] [creator] [1/7] Initializing... (20.9s @ 0.20GB) [INFO] [creator] Version info: 'GraalVM 22.3.1 Java 17 CE' [INFO] [creator] Java version info: '17.0.6+10-LTS' [INFO] [creator] C compiler: gcc (linux, aarch64, 11.3.0) [INFO] [creator] Garbage collector: Serial GC [INFO] [creator] 1 user-specific feature(s) [INFO] [creator] - org.springframework.aot.nativex.feature.PreComputeFieldFeature [INFO] [creator] Field org.springframework.core.NativeDetector#imageCode set to true at build time [INFO] [creator] Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time [INFO] [creator] Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time [INFO] [creator] Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time [INFO] [creator] Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time [INFO] [creator] Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time [INFO] [creator] Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time [INFO] [creator] Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time [INFO] [creator] Error: Image build request failed with exit status 137 [INFO] [creator] unable to invoke layer creator [INFO] [creator] unable to contribute native-image layer [INFO] [creator] error running build [INFO] [creator] exit status 137 [INFO] [creator] ERROR: failed to build: exit status 1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 06:26 min [INFO] Finished at: 2023-03-29T03:36:28+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.2:build-image (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.0.2:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException (⎈|zenjob-prod-absmartly-eks:N/A)

compiling executable, instead of buiding a docker image

is it possible to use this builder for just building the executable, instead of a docker image? for example, using the gradle task gradle nativeCompile?
I have a rock pi 4 with android+ qemu alpine VM, and I can't run docker on It with realistic performance, so I want to run the exec directly on the VM, if that's possible.

Bug: Docker image compression (upx/gzexe)

I'm trying to build an ARM64 docker image of a Spring Boot application (version 3.3.0-M3, Java 17), with Maven, on a Raspberry Pi4. In my pom.xml I specified as indicated on the readme:

...
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>	
</plugin>	
...
<image>												
<builder>dashaun/builder:tiny</builder>
<name>myApp:${project.version}</name>
<env>
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>-H:IncludeResources=".*.properties"</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
<BP_BINARY_COMPRESSION_METHOD>none</BP_BINARY_COMPRESSION_METHOD> 
</env>
</image>
...

I build my application with the following command:

mvn -U clean spring-boot:build-image -Pnative -DskipTests

The operation ends correctly and when I launch the container with the following command:

docker run --device /dev/ttyUSB0 --user 0 -p8080:8080 -e "NATS_SERVER_URL=nats://172.17.0.2:4222" --add-host=host.docker.internal:host-gateway myApp

the application starts correctly. All dependencies, resources, serial port access, reflection etc work fine. But the container has a footprint of around 200Mb (compared to 440Mb of the original container built with a docker file, still too much). So I tried adding compression into my pom.xml

...
<BP_BINARY_COMPRESSION_METHOD>upx</BP_BINARY_COMPRESSION_METHOD>
...

The build ends correctly with a footprint of around 80 Mb (good) but launching the container with the same command I either get no responses (upx) or I get the following error (gzexe): "ERROR: failed to launch: direct exec: no such file or directory".
I tried on WSL, on an AMD64 architecture and the compression works correctly also with tiny builder.
I tried on Raspberry with the "dashaun/builder-arm" builder with the same results with compression enabled but with the "dashaun/builder:base" builder compression works well.

So the question is: should upx/gzexe compression work in ARM64 with tiny builder or is it a bug?

Java 22 support

Firstly a big thanks for this project. It is a life-saver for Macs on the silicon chip.

Just a quick question, will there be support for Java 22 or does the project support LTS releases only?

refusing to run as root error when using pack cli

When using pack cli on my raspberry pi to build an image with the buildpack, it fails with the error message:

refusing to run as root

pack build "test:latest" \
    --path some.jar \
    --env BP_JVM_VERSION=19 \
    --env BP_SPRING_CLOUD_BINDINGS_DISABLED=true \
    --env "BPE_APPEND_JAVA_TOOL_OPTIONS=-XX:+DisableAttachMechanism -Dspring.config.location=classpath:/application.yaml,classpath:/application-prod.yaml" \
    --env "BPE_DELIM_JAVA_TOOL_OPTIONS= " \
    --env BPE_SPRING_PROFILES_ACTIVE=prod \
    --builder "dashaun/builder:tiny"

tiny: Pulling from dashaun/builder
Digest: sha256:f42ac0e9cc13fb04729c41bf2a3354eb3f5ed84c370a0d293b8d7ddee3e7268b
Status: Image is up to date for dashaun/builder:tiny
tiny: Pulling from dashaun/jammy-run
Digest: sha256:5a4cbd1accdfdf302d6a967bc4a6f964914fa22391875944a43801952a344867
Status: Image is up to date for dashaun/jammy-run:tiny
0.16.0: Pulling from buildpacksio/lifecycle
Digest: sha256:f75a04887fced3ae0504a37edb2c0d29d366511cd9ede34dbb90c5282b106e79
Status: Image is up to date for buildpacksio/lifecycle:0.16.0
===> ANALYZING
[analyzer] Restoring data for SBOM from previous image
===> DETECTING
[detector] ERROR: failed to detect: refusing to run as root
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 1 

I'm using just a normal user account, nothing is run as root.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.