How to add a few extra packages with a second composer.json, without composer deleting all my packages?

允我心安 提交于 2020-01-06 08:40:27

问题


I have to migrate a 1000 websites. They are all based on the same base Drupal Docker image.

  • Every website also has a custom Git repository with a custom composer.json to install some extra modules.
  • We would like an easy way to update Drupal on all 1000 websites at the same time, by editing 1 composer.json file.
  • We would also like to give developers of each of the 1000 websites an option to install custom modules.

Unfortunately what happens is that when the 2nd image builds, composer start deleting all the modules installed by the initial composer run. How can I fix this?

$ cat denpal/Dockerfile.cli
FROM php:7.2-cli-drupal

COPY composer.json /app/
COPY scripts /app/scripts
RUN composer install --no-dev
COPY . /app

# Define where the Drupal Root is located
ENV WEBROOT=web

$ cat denpal-example/Dockerfile.cli

FROM testdevelopment/denpal

COPY composer.json /app/
RUN composer install --no-dev

COPY . /app

# Define where the Drupal Root is located
ENV WEBROOT=web

$ cat denpal/composer.json
{
    "type": "project",
    "license": "GPL-2.0+",
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "drupal-composer/drupal-scaffold": "^2.2",
        "cweagans/composer-patches": "~1.0",
        "drupal/core": "~8.0",
        "drush/drush": "~8.0",
        "drupal/console": "~1.0",
        "drupal/config_installer": "1.x-dev",
        "drupal/redis": "^1.0",
        "drupal/poll": "1.2",
        "drupal/search_api": "^1.6",
        "drupal/search_api_solr": "^1.2",
        "drupal/varnish_purge": "^1.10",
        "drupal/purge": "^3.0"
    },
    "require-dev": {
        "behat/mink": "~1.7",
        "behat/mink-goutte-driver": "~1.2",
        "jcalderonzumba/gastonjs": "~1.0.2",
        "jcalderonzumba/mink-phantomjs-driver": "~0.3.1",
        "mikey179/vfsstream": "~1.2",
        "phpunit/phpunit": "~4.8",
        "symfony/css-selector": "~2.8"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "autoload": {
        "classmap": [
            "scripts/composer/ScriptHandler.php"
        ]
    },
    "scripts": {
        "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
        "pre-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "pre-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
        ],
        "post-install-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ],
        "post-update-cmd": [
            "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
        ]
    },
    "extra": {
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"]
        },
        "drupal-scaffold": {
            "excludes": [
                "sites/development.services.yml",
                "sites/example.settings.local.php"
            ]
        }
    }
}

Running this composer run will delete all packages installed by the previous composer run:

$ cat denpal-example/composer.json
{
    "type": "project",
    "license": "GPL-2.0+",
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "drutiny/drutiny": "2.3.*@dev"
    }
}

来源:https://stackoverflow.com/questions/55631640/how-to-add-a-few-extra-packages-with-a-second-composer-json-without-composer-de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!