paketo-buildpacks / php

A Cloud Native Buildpack for PHP
Apache License 2.0
24 stars 9 forks source link

Buildpack support for Drupal 8 #253

Open badri opened 3 years ago

badri commented 3 years ago

I'm attempting to build Drupal 8 using PHP buildpacks. Here's a breakdown of the steps I'm doing.

  1. Scaffold Drupal 8. composer create-project "drupal/recommended-project:^8" drupal

  2. Add the following buildpack.yml.

    ---
    php:
    version: 7.4.*
    webserver: nginx
    webdirectory: web
  3. Build the container image.

pack build -b gcr.io/paketo-buildpacks/php drupal-8 --builder paketobuildpacks/builder:full

  1. Run the new image.

docker run --interactive --tty --env PORT=8080 --publish 8080:8080 drupal-8

The trouble is, the build process creates a symlink of the vendor directory, and running composer install post that updates the autoload.php thus:

<?php

/**
 * @file
 * Includes the autoloader created by Composer.
 *
 * This file was generated by drupal-scaffold.
 *.
 * @see composer.json
 * @see index.php
 * @see core/install.php
 * @see core/rebuild.php
 * @see core/modules/statistics/statistics.php
 */

return require __DIR__ . '//layers/paketo-buildpacks_php-composer/php-composer-packages/vendor/autoload.php';

Which breaks the autoload sequence.

When I edit it back to what it was,

<?php

/**
 * @file
 * Includes the autoloader created by Composer.
 *
 * This file was generated by drupal-scaffold.
 *.
 * @see composer.json
 * @see index.php
 * @see core/install.php
 * @see core/rebuild.php
 * @see core/modules/statistics/statistics.php
 */

return require __DIR__ . '/../vendor/autoload.php';

It works fine. I am not sure why we create symlinks and then run composer install again.

Copying the vendor directory instead of symlinking it would help, although there might be some rationale behind symlinking it which I'm not aware of.

Running composer install after symlinking updates the autoload.php files to reflect the new location of vendor directory.

Happy to triage any approaches/fixes and contribute back to the buildpack, and thanks for the awesome work.

fg-j commented 2 years ago

@paketo-buildpacks/php-maintainers This has been open for a bit. Any update on this? Does the workaround described in the replies to #366 also apply to this use case?