How to use docker with drupal and drush?

前端 未结 8 1750
日久生厌
日久生厌 2021-01-30 23:40

I\'d like to use drush. It needs to run in the drupal container. There\'s also a drush docker repo. But I have no clue how to make it available whithin the drupal container. It\

8条回答
  •  春和景丽
    2021-01-31 00:21

    What I chose to do, is install it will composer in my web container.

    First, I install composer and then I require Drush in the directory that I want.

    Dockerfile example:

    FROM php:7.1-apache
    
    RUN a2enmod rewrite
    
    # Install dependencies
    RUN apt-get update \
        && apt-get install -y git \
        && docker-php-ext-install pdo pdo_mysql \
        && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
        && php -r "if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
        && php composer-setup.php \
        && php -r "unlink('composer-setup.php');" \
        && mv composer.phar /usr/local/bin/composer
    
    RUN cd /var/www/html \
        && composer require drush/drush
    

    If Drush is already a dependency within the composer.json of your project you can just composer install it.

提交回复
热议问题