Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide arm64 image of sample builder(s) #114

Open
retgits opened this issue Oct 11, 2021 · 10 comments
Open

Provide arm64 image of sample builder(s) #114

retgits opened this issue Oct 11, 2021 · 10 comments
Labels
type/enhancement Issue that requests a new feature or improvement.

Comments

@retgits
Copy link

retgits commented Oct 11, 2021

Problem

I tried running the Build an app example in the Buildpack docs, but hit an error while doing so. Any thoughts on how to troubleshoot would be greatly appreciated.

Steps to reproduce

  • Install pack cli: brew install buildpacks/tap/pack
  • Download samples: git clone https://github.com/buildpacks/samples
  • Run build command: pack build sample-app --path samples/apps/java-maven --builder cnbs/sample-builder:bionic

Outcome / Stack trace

$ pack build sample-app --path samples/apps/java-maven --builder cnbs/sample-builder:bionic
bionic: Pulling from cnbs/sample-builder
e4ca327ec0e7: Already exists 
55fae2d3d3bc: Pull complete 
6faf60e5f26d: Pull complete 
3baf523e9da9: Pull complete 
22012278af40: Pull complete 
58b1e653474f: Pull complete 
357fefdf9bc9: Pull complete 
a697cc8a1d5c: Pull complete 
5c2e4179bee1: Pull complete 
c4e3bdcbb8c3: Pull complete 
04f9e5a54d38: Pull complete 
c238db6a02a5: Pull complete 
53a52c7f9926: Pull complete 
0cceee8a8cb0: Pull complete 
a302059dbdba: Pull complete 
db1bbcc47135: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:01b9067fe10704647b0992b56699a4e59431d1162e769706dcf5da5dfda928c8
Status: Downloaded newer image for cnbs/sample-builder:bionic
bionic: Pulling from cnbs/sample-stack-run
e4ca327ec0e7: Already exists 
55fae2d3d3bc: Already exists 
6faf60e5f26d: Already exists 
Digest: sha256:38f19fee4ffd8caafb5550da2d26687feba159528d041101ad99cc7390a0f578
Status: Downloaded newer image for cnbs/sample-stack-run:bionic
0.11.3: Pulling from buildpacksio/lifecycle
5dea5ec2316d: Pull complete 
6d75e71a489d: Pull complete 
Digest: sha256:d6c578fbdf88f2e2594d9907307b17775e648656f62e1ae810d31c804f928cf9
Status: Downloaded newer image for buildpacksio/lifecycle:0.11.3
===> DETECTING
[detector] samples/java-maven 0.0.1
===> ANALYZING
[analyzer] Previous image with name "sample-app" not found
===> RESTORING
===> BUILDING
[builder] ---> Java buildpack
[builder] ---> Installing JDK
[builder] ---> Running Maven Wrapper
[builder] qemu: uncaught target signal 11 (Segmentation fault) - core dumped
[builder] /cnb/buildpacks/samples_java-maven/0.0.1/bin/build: line 116:    60 Segmentation fault      ./mvnw clean install -B -DskipTests
[builder] ERROR: failed to build: exit status 139
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51

Environment

  • pack CLI: 0.21.1+git-e09e397.build-2823
  • docker: Docker version 20.10.7, build f0df350
  • OS: macOS 11.6 (with an Apple M1 chip)
@jromero
Copy link
Member

jromero commented Nov 2, 2021

FWIW, this would be an issue with qemu, see docker/for-mac#5123 (comment).

What we can do, and would need to test, is create an arm64 sample builder image. Marking this as a feature request and updating the title.

@jromero jromero changed the title Error running sample in docs Provide arm64 image of sample builder(s) Nov 2, 2021
@jromero jromero added the type/enhancement Issue that requests a new feature or improvement. label Nov 2, 2021
@odidev
Copy link

odidev commented Nov 15, 2022

Hi Team, I am also interested in Linux/ARM64 support for the cnbs docker images.
Do you have any plans to roll out the official Linux/ARM64 docker images soon?

@natalieparellano
Copy link
Member

cc @AidanDelaney

I am not on the learning team, but my sense is that we could use some helping hands from folks willing to push this forward incrementally. If anyone would be interested in getting involved, I'd be happy to provide support based on my experience contributing to this repository.

@odidev
Copy link

odidev commented Nov 16, 2022

Thank you for the response.

The cnbs images are built and pushed to dockerhub via the Makefile. It seems like we cannot create multi-arch docker images using pack. Pack can build native images for both Linux/AMD64 and Linux/ARM64 separately. So, to build and release images for ARM64 (image names different for amd64 and arm64), Makefile needs to be reframed with platform-specific checks to build and push images for separate platforms (AMD64 and ARM64) and then other files using these images also need to be reframed with platform-specific checks to work for both the platforms. Also, GitHub Actions config files will use self-hosted runners to support the build and push for Linux/ARM64 images.

May I know, is there a way we can build multi-arch images using pack? Or else, IMO, the above requires a lot of changes in the source code in multiple files.

Kindly provide your suggestions on the same.

@odidev
Copy link

odidev commented Nov 18, 2022

Continuing with my previous comment, to create the application image for “myapp”, I tried creating the builder image “sample-builder:bionic” natively for Linux/ARM64. However, “myapp” failed with the following logs:

$ pack build myapp --builder sample-builder:bionic 

0.14.1: Pulling from buildpacksio/lifecycle 
Digest: sha256:56019ba74831e3444f33ee8c0201f18cc300213bac353b8b6a79c7a1669b7a49 
Status: Image is up to date for buildpacksio/lifecycle:0.14.1 
===> ANALYZING 
[analyzer] Previous image with name "myapp" not found 
===> DETECTING 
[detector] exec /cnb/lifecycle/detector: exec format error 

Below are the changes I did in the source code for Linux/ARM64:

  • Changed the PLATFORM to arm64 in stacks/build_stack.sh.
  • Downloaded yj and jq for Arm in Dockerfiles present at <stacks/alpine/build/Dockerfile> and <stacks/bionic/build/Dockerfile>.
  • Changed the image names from cnbs/<image_name> to <image_name> to avoid pulling the official cnbs images from dockerhub, and use the natively built images.
  • Downloaded jdk 11 for aarch64 in <buildpacks/kotlin-gradle/bin/build> and <buildpacks/java-maven/bin/build>.

Then, I built the sample-builder:bionic via make as below:

$ make build-linux-stacks build-linux-packages build-linux-builders 

Do you have any suggestions on the same?

@natalieparellano
Copy link
Member

@odidev thank you for looking into this! You are right that we can't create cross-platform builders with pack today; this issue (buildpacks/pack#1459) would change that, but is awaiting someone to take it up.

Regarding the error mentioned above - can you check if the lifecycle in the builder is compiled for arm? The error is either coming from the lifecycle or the buildpack, so we need to ensure both are able to run on arm architecture. I see that the analyzer ran fine, but pack might have been using the "lifecycle image" for that step so we need to confirm what was actually on the builder itself.

@AidanDelaney
Copy link
Member

Only the very latest lifecycle has fixes to pick up arm64 builders. We would love some help with buildpacks/docs#533 :)

@odidev
Copy link

odidev commented Nov 23, 2022

I followed this document < https://buildpacks.io/docs/app-developer-guide/build-an-arm-app/ > to build the application image on Arm directly by invoking the lifecycle image, and successfully created the application container.

Also, I followed this document: < https://github.com/dmikusa/paketo-arm64#readme > in paketo-arm64 repo to natively build the builder image for Arm and created the application container bound to port 8080. I can curl localhost:8080 successfully.

$ curl -s http://localhost:8080/actuator/health | jq . 

{ 
  "status": "UP" 
} 

@AidanDelaney
Copy link
Member

@odidev Congratulations on becoming an innovator in the multi-architecture buildpacks space :) If you have the time it would be great to see you in our regular Thursday meetings (https://buildpacks.io/community/). We would appreciate your perspective.

@AidanDelaney
Copy link
Member

This is a longer term goal for us. We're now in a position that it should work, i.e. we've made all the necessary changes to pack. Keeping this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

No branches or pull requests

5 participants