Closed marcusball closed 2 years ago
@marcusball having a discussion on Slack about this here: https://cloud-native.slack.com/archives/C0331B61A1Y/p1646156479825739?thread_ts=1646156011.522369&cid=C0331B61A1Y
@marcusball an update here:
@natalieparellano dug into the digitaloceanapps/apps-builder
and found that there's a custom entrypoint ("ENTRYPOINT [\"/.app_platform/build.sh\"]"
). It's then that script that expects an environment variable.
As per the spec, pack only provides the environment variables through a file system interface and doesn't set the environment variables on execution of detector
. If I'm not mistaken, detector
then reads those environment variables from the file system and provides them to the buildpack's detect
execution and that's what being referred to in this issue.
Relevant spec wording:
User-provided environment variables MUST be supplied by the platform as files in the
/env/ directory. Each file SHALL define a single environment variable, where the file name defines the key and the file contents define the value. User-provided environment variables MAY be modified by prior buildpacks before they are provided to a given buildpack.
The platform SHOULD NOT set user-provided environment variables directly in the lifecycle execution environment.
To summarize, it appears that the builder image you are using is expected to run in a very precise way and may arguably be non-compliant with the specification.
Please let me know if something I mentioned is still unclear.
Also, I was unable to find any reference online to the builder. If you can, could you relay this information to the builder author(s)?
Thank you for the reply!
As per the spec, pack only provides the environment variables through a file system interface and doesn't set the environment variables on execution of detector. If I'm not mistaken, detector then reads those environment variables from the file system and provides them to the buildpack's detect execution and that's what being referred to in https://github.com/buildpacks/pack/issues/83.
Alright, that's the conclusion I eventually came to after filing the issue, but this is my first time trying to use Pack, so I wasn't confident I was interpreting the spec correctly.
Luckily, I ended up being able to work around once I dug into the builder image and realized it was basically just a bundle of Heroku builders with the additional custom entrypoint scripts.
I'll close this issue as it seems resolved. Thanks for your feedback @marcusball !
Summary
The builder I'm trying to use requires some environment variables to be set while it is building. I can run the builder directly though docker like this,
docker run -t -e "MY_ENV=example" --rm example/builder
, and it works fine. However, if I try to run the builder with Pack,pack build example-image -B example/builder --env "MY_ENV=example"
the detector phase throws an error saying the environment variable is not defined. If I configure Pack to trust the builder, it also fails.I've tried defining the variables via
--env
, I've tried putting them in a file an passing it via--env-file
, and I've tried putting them in a.env
file just to see if that would do anything (even though I wasn't expecting it to).Based on this issue, I'm under the impression that these variables should be present during the detector phase. I'll admit, I could also be completely misunderstanding the meaning of "build-time" if the builder image running is the "image runtime" during which the variables are not available. If I am misunderstanding this, when is build-time if not when the builder is running?
The builder I'm trying to use is
digitaloceanapps/apps-builder
with the requiredGIT_SOURCE_URL
variable.Reproduction
Steps
pack build problem-test -B digitaloceanapps/apps-builder --verbose --env "GIT_SOURCE_URL=https://github.com/buildpacks/pack"
; the git URL and the working directory do not really matter for this issue, I'm just using the Pack repository as an example.Current behavior
If the builder is untrusted:
If the builder is trusted:
Expected behavior
The
GIT_SOURCE_URL
should be defined in the builder, and the builder should be able to proceed past the "initializing build" step. Ex:Environment
pack info
docker info