简体   繁体   English

dockerfile:`composer install --no-dev 安装开发依赖项,然后立即删除它们

[英]dockerfile: `composer install --no-dev installs dev-dependencies, then deletes them straight away after

My docker-compose setup does (I think) some wierd things.我的 docker-compose 设置确实(我认为)一些奇怪的事情。

I am installing from this composer.json :我正在从这个composer.json安装:

{
    "require-dev":  {
        "phpunit/phpunit":"~9.0",
        "squizlabs/php_codesniffer": "~3.0",
        "fzaninotto/faker": "~1.9"
    },
    "require": {
        "doctrine/orm": "2.7.2",
        "haydenpierce/class-finder": "0.4.2"
    },
    "autoload" : {
        "psr-4": {
            "WebApp\\": "src/"
         }
    },
    "autoload-dev" : {
        "psr-4": {
            "WebApp\\Tests\\" : "tests/"
        }
    }
}

And my dockerfile looks like:我的dockerfile看起来像:

FROM php:7.4.4-apache

#Install git
RUN php -v
RUN apt-get update && apt-get install -y git
RUN apt-get install zip unzip
RUN docker-php-ext-install pdo pdo_mysql mysqli

#enable Ubuntu module 'URL rewrite'
RUN a2enmod rewrite

#Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer

#setup database secrets file
COPY db_secret.prod.php /etc/db_secret.prod.php

#Make php error log file
RUN touch /var/log/php-error.log
RUN chmod 755 /var/log/php-error.log

#copy across necessary files
COPY . /var/www/
RUN rm /var/www/db_secret.prod.php

#change root that server runs files from
RUN sed -i 's+/var/www/html+/var/www/src/html+i' /etc/apache2/sites-available/000-default.conf

#Install php testing
RUN cd .. && composer update && composer install --no-dev

#RUN cd .. && vendor/bin/doctrine orm:schema-tool:create

EXPOSE 80

When running composer install I get:运行composer install我得到:

Step 15/16 : RUN cd .. && composer update && composer install --no-dev
 ---> Running in 2980b48bbbc0
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 55 installs, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.8.0): Downloading (100%)         
  ...abridged for brevity...       
  - Installing fzaninotto/faker (v1.9.1): Downloading (100%)         
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing symfony/process
symfony/console suggests installing psr/log (For using the console logger)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
doctrine/orm suggests installing symfony/yaml (If you want to use YAML Metadata Mapping Driver)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-invoker suggests installing ext-pcntl (*)
phpunit/php-code-coverage suggests installing ext-pcov (*)
phpunit/php-code-coverage suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
37 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 0 installs, 0 updates, 31 removals
  - Removing webmozart/assert (1.8.0)
 ...abridged for brevity...
  - Removing fzaninotto/faker (v1.9.1)
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
19 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Can anyone tell me why it would install and then remove the dev packages instead of just omitting them from the original install?谁能告诉我为什么它会安装然后删除开发包,而不是从原始安装中忽略它们?

The container for the dockerfile is php744-apache dockerfile 的容器是 php744-apache

Pretty simple: you run composer update (which will update the list of packages, and install them), and afterwards you run composer install --no-dev .很简单:你运行composer update (这将更新软件包列表并安装它们),然后你运行composer install --no-dev

Just out of curiosity: this is only done when updating the Docker image.只是出于好奇:这仅在更新 Docker 映像时完成。 Is there any good reason for this?这有什么好的理由吗? Why don't you decouple the image and the source code running in that image?为什么不将图像和在该图像中运行的源代码解耦?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何强制依赖项的dev-dependencies也可以用composer安装? - How to force dev-dependencies from a dependency to also install with composer? ClassNotFoundError with Composer install --no-dev in symfony - ClassNotFoundError with Composer install --no-dev in symfony 为什么composer安装--no-dev不起作用? - Why composer install --no-dev does not work? 具有dev依赖项的Composer安装包 - Composer install package with dev dependencies 运行 composer --no-dev 时出现望远镜错误 - Telescope error when running composer --no-dev Symfony 4,迁移到生产环境后,命令“ composer install --no-dev”失败(ClassNotFoundException:WebProfilerBundle) - Symfony 4, migration to production, the command “composer install --no-dev” fail (ClassNotFoundException : WebProfilerBundle) 使用命令“composer install --no-dev --optimize-autoloader”下载翼手龙时出错 - Error downloading Pterodactyl with the command "composer install --no-dev --optimize-autoloader" 通过--no-dev时,作曲家的php版本失败 - Composer failing with php version when --no-dev is passed 我如何告诉magallanes使用--no-dev执行作曲家? - How do I tell magallanes to execute composer with --no-dev? Composer 仅安装 require 和 require-dev 块中的内容,而不是使用本地存储库时的依赖项 - Composer installs only what's in the require and require-dev blocks and not the dependencies when using local repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM