jincod / dotnetcore-buildpack

Heroku .NET Core Buildpack
MIT License
750 stars 360 forks source link

Move to cloud-native layout #189

Open david-caro opened 9 months ago

david-caro commented 9 months ago

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.

jincod commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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
david-caro commented 9 months ago

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

jincod commented 9 months ago

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?