buildpacks / pack

CLI for building apps using Cloud Native Buildpacks
https://buildpacks.io
Apache License 2.0
2.56k stars 286 forks source link

Buildpack `from=all` sandwich not working 🥪 #609

Closed ameyer-pivotal closed 4 years ago

ameyer-pivotal commented 4 years ago

Summary

Supplying a custom buildpack via the --buildpack flag both before and after a --buildpack from=all only applies one of the provided buildpacks.


Reproduction

Steps

From the bug directory, after extracting the attached zip (this directory contains two very simple buildpacks that always pass detection):

pack build myapp --builder cloudfoundry/cnb:bionic -p ~/workspace/samples/apps/java-maven/ --buildpack mybp --buildpack from=builder --buildpack mybp2
Current behavior

Detection only applies custom buildpack 0.0.1:

...
===> DETECTING
[detector] 7 of 16 buildpacks participating
[detector] custom.buildpack                    0.0.1
[detector] paketo-buildpacks/bellsoft-liberica 2.4.1
[detector] paketo-buildpacks/maven             1.2.1
[detector] paketo-buildpacks/executable-jar    1.2.2
[detector] paketo-buildpacks/apache-tomcat     1.1.2
[detector] paketo-buildpacks/dist-zip          1.2.2
[detector] paketo-buildpacks/spring-boot       1.5.2
===> ANALYZING
...
Expected behavior

Custom buildpack 0.0.1 should be applied before the builder's buildpacks, and custom buildpack 0.0.2 should be applied after:

...
===> DETECTING
[detector] 8 of 16 buildpacks participating
[detector] custom.buildpack                    0.0.1
[detector] paketo-buildpacks/bellsoft-liberica 2.4.1
[detector] paketo-buildpacks/maven             1.2.1
[detector] paketo-buildpacks/executable-jar    1.2.2
[detector] paketo-buildpacks/apache-tomcat     1.1.2
[detector] paketo-buildpacks/dist-zip          1.2.2
[detector] paketo-buildpacks/spring-boot       1.5.2
[detector] custom.buildpack                    0.0.2
===> ANALYZING
...

Environment

pack info
Pack:
  Version:  0.10.0+git-06d9983.build-259
  OS/Arch:  darwin/amd64

Default Lifecycle Version:  0.7.2

Config:
  default-builder-image = "cloudfoundry/cnb:bionic"
zmackie commented 4 years ago

This is a result of the detection logic: https://github.com/buildpacks/lifecycle/blame/3b41bc40cc1eca7aeca47b4612b01f2d348a12d5/detector.go#L256-L258

Given two buildpacks of the same ID and different versions, at the moment only one will be considered for detection.

The buildpacks in your zip file have the same ID.

When I modified the ID, this works as intended:

sing build cache volume pack-cache-883267f9b9ea.build
===> CREATING
[creator] ---> DETECTING
[creator] ======== Results ========
[creator] pass: custom.buildpack@0.0.1
[creator] pass: paketo-buildpacks/bellsoft-liberica@2.5.3
[creator] skip: paketo-buildpacks/gradle@1.2.0
[creator] pass: paketo-buildpacks/maven@1.4.0
[creator] skip: paketo-buildpacks/sbt@1.2.0
[creator] pass: paketo-buildpacks/executable-jar@1.2.3
[creator] pass: paketo-buildpacks/apache-tomcat@1.1.3
[creator] pass: paketo-buildpacks/dist-zip@1.3.0
[creator] pass: paketo-buildpacks/spring-boot@1.5.3
[creator] skip: paketo-buildpacks/procfile@1.3.3
[creator] skip: paketo-buildpacks/azure-application-insights@1.1.3
[creator] skip: paketo-buildpacks/debug@1.2.3
[creator] skip: paketo-buildpacks/google-stackdriver@1.1.3
[creator] skip: paketo-buildpacks/jmx@1.1.3
[creator] skip: paketo-buildpacks/encrypt-at-rest@1.2.3
[creator] skip: paketo-buildpacks/image-labels@1.0.3
[creator] pass: custom.buildpack2@0.0.2 <-------------- different ID
ameyer-pivotal commented 4 years ago

@zmackie 🤦I should have tried that. Thanks!