Skip to content

Comments

Move to cloud-native layout#189

Open
david-caro wants to merge 2 commits intojincod:masterfrom
david-caro:move_to_cnb
Open

Move to cloud-native layout#189
david-caro wants to merge 2 commits intojincod:masterfrom
david-caro:move_to_cnb

Conversation

@david-caro
Copy link

This allows to use the buildpack with the newer lifecycle images.

Currently the supported heroku builder (heroku/builder:22) uses the lifecycle version >18, and that one only supports buildpacks API >= 0.7

See https://github.com/buildpacks/lifecycle for details.

  • Moved bin/compile -> bin/build
  • Using the CNB environment variables instead of arguments for the scripts
  • Added buildpack.toml and package.toml to meet the buildpack 0.10 spec.
  • Removed the bin directory from the gitignore.

This allows to use the buildpack with the newer lifecycle images.

Currently the supported heroku builder (heroku/builder:22) uses the
lifecycle version >18, and that one only supports buildpacks API >=
0.7

See https://github.com/buildpacks/lifecycle for details.

* Moved bin/compile -> bin/build
* Using the CNB environment variables instead of arguments for the
  scripts
* Added buildpack.toml and package.toml to meet the buildpack 0.10
  spec.
* Removed the bin directory from the gitignore.

Signed-off-by: David Caro <david@greyllama.cc>
@jincod
Copy link
Owner

jincod commented Dec 11, 2023

Hello @david-caro

Thank you for you contribution💪

I've reviewed the changes. As I can see there are the breaking change for Heroku buildpack. The bin/compile script is requirable. Do you have an idea how can we adopt that?

@david-caro
Copy link
Author

Oh!

I think this is not directly needed actually, it seems heroku provides a "cloud native"-ified version of each buildpack at the url:

https://buildpack-registry.heroku.com/cnb/jincod/dotnetcore

(note the /cnb in the path)

And it even fixes the return code for the detect script and such:

#!/usr/bin/env bash

# fail hard
set -o pipefail

bp_dir="$(
    cd "$(dirname "$0")/.."
    pwd
)" # absolute path
target_dir="${bp_dir}/target"

"${target_dir}/bin/detect" "$(pwd)" >/dev/null 2>&1

EXITCODE=$?

case $EXITCODE in
1) exit 100 ;;
*) exit $EXITCODE ;;
esac

So the solution there seems to be to pull the buildpack from that url instead of using the code from the repository (or the releases page).

Let me try see if that solves it on my side, but there might not be any changes required :)

@david-caro
Copy link
Author

Unfortunately does not work either xd
I think that we need at least to add the buildpack.toml file specifying buildpack api support for >=0.10.

vagrant@bullseye:~/AspNetCoreDemoApp$ pack build --buildpack heroku/nodejs --buildpack https://buildpack-registry.heroku.com/cnb/jincod/dotnetcore --builder heroku/builder:22 kk
22: Pulling from heroku/builder
Digest: sha256:f170006bab1d150d8f14f032123f3b5c593da6c16c60542da8b02272eaee5b7a
Status: Image is up to date for heroku/builder:22
22-cnb: Pulling from heroku/heroku
Digest: sha256:889a44f22d6daceaa649f73ebab596f6c75a08f506a84034e727304eca37c793
Status: Image is up to date for heroku/heroku:22-cnb
Downloading from https://buildpack-registry.heroku.com/cnb/jincod/dotnetcore
1.83 MB/-1 B
===> ANALYZING
Restoring data for SBOM from previous image
===> DETECTING
ERROR: failed to set API for Buildpack 'jincod/dotnetcore@0.1': buildpack API version '0.4' is incompatible with the lifecycle
ERROR: failed to build: executing lifecycle: failed with status code: 12

Note that you can't use the pack cli directly on the code without making those changes either (as the code itself does not have the needed scripts/files):

# Will not work without this PR
vagrant@bullseye:~/AspNetCoreDemoApp$ pack build --buildpack heroku/nodejs --buildpack ../dotnetcore-buildpack/ --builder heroku/builder:22 myimage

Signed-off-by: David Caro <dcaro@wikimedia.org>
@david-caro
Copy link
Author

david-caro commented Dec 11, 2023

I added the link from build to compile, can you try it out @jincod?

@jincod
Copy link
Owner

jincod commented Dec 19, 2023

Hi @david-caro,

Thank you for the update. I will run some tests.

BTW Have you checked this project https://github.com/paketo-buildpacks/dotnet-core?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants