paketo-buildpacks / dotnet-publish

Apache License 2.0
3 stars 4 forks source link

Restructure: This buildpack should require needed `build` dependencies #85

Closed joshzarrabi closed 3 years ago

joshzarrabi commented 4 years ago

Background

The buildpack currently requires itself on build, and dotnet-sdk, dotnet-runtime, node, dotnet-aspnetcore, and icu on build and launch. It provides a built version of the application named dotnet-application in the form of a ready to go dll file.

Because this buildpack does not run the dll, it only builds it, it does not need to require any of these dependencies on launch, and it should never require itself.

Proposal

In order to conform the the restructure rfc, this buildpack should

Note that this buildpack will not specify the versions of any of the dependencies it requires. The dotnet-execute buildpack will be responsible for requesting all versions.

This buildpack should

joshzarrabi commented 3 years ago

Acceptance steps for requires

Attempt to build an app that does not require dotnet-aspnetcore while including the dotnet-core-aspnet buildpack, and watch it fail detection, saying dotnet-aspnetcore is unused.

$ pushd dotnet-publish/integration/testdata/console_app
$ pack build --verbose my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/dotnet-core-aspnet -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute
base: Pulling from paketobuildpacks/builder
...........
===> DETECTING
----
[detector] fail: paketo-buildpacks/dotnet-core-aspnet@0.0.196 provides unused dotnet-aspnetcore
[detector] ERROR: No buildpack groups passed detection.
[detector] ERROR: Please check that you are running against the correct path.
[detector] ERROR: failed to detect: no buildpacks participating

Remove dotnet-core-aspnet from the list of buildpacks and watch it succeed

$ pack build my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute

base: Pulling from paketobuildpacks/builder
.......
===> DETECTING
[detector] paketo-buildpacks/icu                 0.0.99
[detector] paketo-buildpacks/dotnet-core-runtime 0.0.201
[detector] paketo-buildpacks/dotnet-core-sdk     0.0.196
[detector] paketo-buildpacks/dotnet-publish      0.1.0
[detector] paketo-buildpacks/dotnet-execute      0.2.1
===> ANALYZING

This proves the buildpack is working as expected because the dotnet-core-aspnet buildpack is providing itself, but the the dotnet-publish buildpack is not requiring it, causing a mismatch.


We can see the same thing with node

$ pack build --verbose my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/node-engine -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute

===> DETECTING
....
[detector] Resolving plan... (try #1)
[detector] fail: paketo-buildpacks/node-engine@0.1.4 provides unused node
[detector] Resolving plan... (try #2)
[detector] fail: paketo-buildpacks/node-engine@0.1.4 provides unused node
[detector] ERROR: No buildpack groups passed detection.

Now if we build an app that needs dotnetcore-aspnet, but don't supply the dotnet-core-aspnet buildpack we can see pack build fail, because the dotnet-publish buildpack will require it, and nothing will be there to provide it.

$ pushd dotnet-publish/integration/testdata/source-2.1-aspnet
$ pack build --verbose my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk  -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute

===> DETECTING
......
[detector] Resolving plan... (try #1)
[detector] fail: paketo-buildpacks/dotnet-publish@0.1.0 requires dotnet-aspnetcore
[detector] ERROR: No buildpack groups passed detection.
....

We can run the same experiment with an app that requires node

$ pushd dotnet-publish/integration/testdata/angular_msbuild_dotnet_2.1
$ pack build --verbose my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/dotnet-core-aspnet  -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute

===> DETECTING
[detector] ======== Results ========
----
[detector] Resolving plan... (try #1)
[detector] fail: paketo-buildpacks/dotnet-publish@0.1.0 requires node
[detector] ERROR: No buildpack groups passed detection.

With the four above examples, we can prove that the dotnet-publish buildpack requires the node and dotnetcore-aspnet requirements correctly.

Acceptance steps for provides

In order to prove the buildpack correctly provides the app in a layer named dotnet-application, we can attempt to build an app with an old version of dotnet-execute, which still requires the application as build Here we will use v0.0.180.

$ pack build --verbose my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/dotnet-core-aspnet  -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute:0.0.180

===> DETECTING
[detector] ======== Results ========
....
[detector] fail: paketo-buildpacks/dotnet-publish@0.1.0 provides unused dotnet-application
[detector] ERROR: No buildpack groups passed detection.

Furthermore, to prove this provided layer contains the application, we can look at the logs of a successful app run, and see that the dotnet-execute buildpack runs the app out of the layer

$ pack build my-app -b gcr.io/paketo-buildpacks/icu -b gcr.io/paketo-buildpacks/dotnet-core-runtime -b gcr.io/paketo-buildpacks/dotnet-core-sdk -b gcr.io/paketo-buildpacks/dotnet-publish -b gcr.io/paketo-buildpacks/dotnet-execute

....
[builder] Paketo .NET Execute Buildpack 0.2.1
[builder]   Assigning launch processes
[builder]     web: dotnet /layers/paketo-buildpacks_dotnet-publish/publish-output/console.dll --urls http://0.0.0.0:${PORT:-8080}
....