首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dockerfile:` `composer install --no-dev安装dev依赖项,然后立即删除它们

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

Stack Overflow用户
提问于 2020-06-16 05:04:32
回答 1查看 357关注 0票数 0

我的docker-compose设置(我认为)做了一些奇怪的事情。

我正在从此composer.json安装

代码语言:javascript
复制
{
    "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/"
        }
    }
}

我的dockerfile看起来像这样:

代码语言:javascript
复制
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

当运行composer install时,我得到:

代码语言:javascript
复制
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!

谁能告诉我为什么它会安装然后删除开发包,而不是在原始安装中省略它们?

dockerfile的容器是php744-apache

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-16 14:55:21

非常简单:运行composer update (这将更新软件包列表并安装它们),然后运行composer install --no-dev

出于好奇:只有在更新Docker镜像时才会这样做。这有什么好的原因吗?为什么不将图像和运行在该图像中的源代码解耦?

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62397014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档