GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
967 stars 144 forks source link

PHP Extensions Mismatch: App Engine Standard <> gcr.io/buildpacks/builder #393

Open iamacarpet opened 5 months ago

iamacarpet commented 5 months ago

Describe the bug

The PHP extensions included in the main builder (gcr.io/buildpacks/builder) don't seem to match those on App Engine Standard.

Tested against PHP 8.3, some of the versions don't match and opentelemetry is entirely missing.

Additional context How are you using GCP buildpacks?

Did this used to work?

First time testing / unknown

What language is your project primarily written in? (Python/Java/Node.js/Go/etc.)

PHP 8+, specifically testing PHP 8.3

Steps To Reproduce Steps to reproduce the behavior:

  1. pack build sample-php --builder=gcr.io/buildpacks/builder
  2. docker run --entrypoint /bin/bash -it sample-php
  3. ls -lh /layers/google.php.runtime/php/lib/php/extensions/no-debug-non-zts-20230831/

vs

  1. docker run --entrypoint /bin/bash -it gcr.io/gae-runtimes/buildpacks/php83/run:latest
  2. ls -lh /usr/lib/php/extensions/no-debug-non-zts-20230831/

Expected behavior A clear and concise description of what you expected to happen.

At the most basic level, expect opentelmetry.so to be present, and when loading PHP, all of the module versions to match.

Actual behavior What actually happened?

opentelemetry.so isn't present, version numbers mismatch.

If applicable, add screenshots / logs / error messages

jama22 commented 5 months ago

This is some what "as designed". The base images in the GAE context are designed to capture more use cases supporting we applications. The "generic" builders (gcr.io/buildpacks/builder) are much more stripped down.

@iamacarpet I'm assuming you're looking for the same set of extensions so you have some portability between GAE and manually building & deploying to Cloud Run / k8s? You can try using gcr.io/gae-runtimes/buildpacks/google-gae-22/php/builder with pack

iamacarpet commented 5 months ago

Thanks @jama22 ,

Yes, exactly - see my answer to your other reply here for a full explanation:

https://github.com/GoogleCloudPlatform/buildpacks/discussions/300#discussioncomment-8827712

But yes, broadly, full portability & equality between App Engine and Cloud Run, since that is the direction we are being pushed in (and have been for some time).

I have tried using the gcr.io/gae-runtimes/buildpacks/google-gae-22/php/builder image, but without all of the environment variables from an App Engine Standard build (pulled from Cloud Run), it's still using the same PHP runtime (tar.gz) as the generic builder, not the App Engine run image.

Pulling the environment variables from the App Engine Standard build seemed to make it choose the run image, but ran me into more errors down the line - I ended up giving up on that, as it was wasting too much time.

kennethye1 commented 5 months ago

There's a difference between the builder and the run image. The extensions are enabled on the run image. You can specify the run image specifically via

pack build sample-php --builder=gcr.io/buildpacks/builder --run-image gcr.io/gae-runtimes/buildpacks/php83/run:latest

sl0wik commented 4 months ago

@iamacarpet you can try:

pack build sample-php --builder gcr.io/buildpacks/builder:latest --run-image gcr.io/buildpacks/google-22/run:latest

I keep on looking for a better way.

I would expect that --builder=gcr.io/gae-runtimes/buildpacks/google-gae-22/php/builder:latest --run-image=gcr.io/gae-runtimes/buildpacks/google-gae-22/php/run:latest is the right one but it would throw ERROR: failed to launch: change to app directory: chdir /workspace: permission denied