GoogleCloudPlatform / php-docker

Docker images for running PHP applications on the App Engine Flexible Runtime
Apache License 2.0
188 stars 83 forks source link

Laravel 8 - build failed in google app engine flexible environment #534

Open bhaidar opened 3 years ago

bhaidar commented 3 years ago

Hello, I have a Laravel PHP app with the following:

runtime_config: document_root: public whitelist_functions: proc_open automatic_scaling: min_num_instances: 1 max_num_instances: 1 resources: cpu: 1 memory_gb: 0.5 disk_size_gb: 10 env_variables:

See substitution variables for Google Cloud Build Trigger


- cloud_build.yaml

steps:

When the Cloud Build Trigger runs, I get the following error:

Step #0: Digest: sha256:1f43a583e4c10b1758647be47b9fb5f9659227ef266978694acbb7981e4ee093
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:1f43a583e4c10b1758647be47b9fb5f9659227ef266978694acbb7981e4ee093
Step #0: gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:1f43a583e4c10b1758647be47b9fb5f9659227ef266978694acbb7981e4ee093
Step #0: + php /builder/create_dockerfile.php create --php73-image gcr.io/google-appengine/php73@sha256:bee53597a0df4167547fd9c2a501484e8c5d03831298f50c1db0e9cdcd915a88 --php72-image gcr.io/google-appengine/php72@sha256:c3f3636b89aab3a83ab288a0108f767a4d56002c9a214b17b5fe93b9ba5f8bbf --php71-image gcr.io/google-appengine/php71@sha256:9d39f66c4e0b7c9a9590ed27373b8c18e79a6cde3dbf48c284ffc5f3fd99d12a
Step #0: [09-Jun-2021 19:06:00 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 232
Step #0:
Step #0: Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 232
Step #0: [09-Jun-2021 19:06:00 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 232
Step #0:
Step #0: Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 232
Step #0: [09-Jun-2021 19:06:00 UTC] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 174
Step #0:
Step #0: Warning: array_key_exists() expects parameter 2 to be array, null given in /builder/src/Builder/GenFilesCommand.php on line 174
Step #0: [09-Jun-2021 19:06:00 UTC] PHP Fatal error: Uncaught Error: Unsupported operand types in /builder/src/Builder/GenFilesCommand.php:279
bhaidar commented 3 years ago

For some reason, the variable appYaml is always null, although there is an app.yaml file at the root of the app.

bhaidar commented 3 years ago

Actually, this is a bug in GenFileCommands.php file

 protected function envsFromAppYaml()
            {
                $ret = array_key_exists('env_variables', $this->appYaml)
                    ? $this->appYaml['env_variables']     
                    : [];

                $removedEnvVars = [];
                foreach (self::REMOVED_ENV_VARS as $k) {
                    if (array_key_exists($k, $ret)) {
                        $removedEnvVars[] = $k;
                    }
                }

                if (count($removedEnvVars) > 0) {
                    throw new RemovedEnvVarException(
                        "There are environment variables which are no more"
                        . "supported. Remove the following keys in "
                        . "'env_variables': "
                        . implode(" ", $removedEnvVars)
                    );
                }
                return $ret;
            }

If we leave the app.yaml file with a section like this:

env_variables:

Then $ret is null. There is no checking for null, it's being used right away inside array_key_exists().