To launch my containers in a permanent state as background processes I run the following command: docker-compose up -d drupal_dev/modules:/var/www/html/modules Here is my docker-compose.yml file: version: '2.1' Notice my docker-compose.yml file is using image:mysql:5.7 Note: Mysql:latest Docker images looks to run version 8, which does not play well with Drupal intalls out of the box. I want to be able to launch a Drupal container, launch a MySQL container, and map the Drupal modules folder to my local machine for easy code access. yml file to configure how I launch these containers. Go ahead, break Drupal! I’ll use _docker-compose– with a. I can now launch as many of these images as containers that I want. Our Dockerfile is now complete! Lets run it and build our Docker image with the following (I call my image drupal-docker-dev:001) docker build. RUN echo 'opcache.enable=0' > /usr/local/etc/php/conf.d/debugging.ini RUN cd /usr/sbin/ & ln -s /var/www/html/vendor/drush/drush/drush drush RUN cd /var/www/html/ & composer require drush/drush RUN apt-get update & apt-get install git -y ![]() Our full Dockerfile will contain the following at this point: FROM drupal:8.7.5-apache It can get annoying! To disable Opcache, we disable it with a flag in our configuration INI files.Īdd the following to your Dockerfile: RUN echo 'opcache.enable=0' > /usr/local/etc/php/conf.d/debugging.ini Essentially what this means in the debugging world is if you change a file and refresh the page too fast, you won’t see the change. If you are not familiar with Opcache, this is a feature introduced in PHP 5.5 that loads your scripts into memory and executes them from there, eliminating the need for PHP to process your scripts on every page load. While Opcache can be extremely useful when running PHP in production, this caching feature can make writing and debugging PHP confusing. ![]() RUN echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so' > /usr/local/etc/php/conf.d/debugging.ini RUN touch /usr/local/etc/php/conf.d/debugging.ini ![]() Add the following to the end of our working Dockerfile: #install XDEBUG We can include the instructions to have XDEBUG installed for us in our Dockerfile. Installing XDEBUGĪs it turns out having XDEBUG installed to step through PHP code, including Drupal and modules is very handy. Now Drush will be available on the command line. Then put Drush on the path: RUN cd /usr/sbin/ & ln -s /var/www/html/vendor/drush/drush/drush drush Add this line to the Dockerfile: RUN apt-get update & apt-get install gitĪnd to now install Drush, add the following lines to the Dockerfile: RUN cd /var/www/html/ & composer require drush/drush ![]() The image from Docker Hub does not include Drush, but we can use our new Composer capabilities to install it, and then put it on the path.Ī quick pre-requisite for installing Drush (or any package using Composer) we’ll need to install GIT. sh file looks like this: #!/bin/shĪnd then add the following to your Dockerfile to include and run this file during build time, so our full Dockerfile looks like this: FROM drupal:8.7.5-apacheĪt this point if we were to build our Docker image we would have Drupal core ready to be installed and Composer available to install packages and modules. To simplify the install process I’ve included the instructions in a composer.sh file that can be copied and run during Docker image build time, just ensure the composer.sh file is in the same directory as the Dockerfile. phar file, and then copy to your system path. The process for installing Composer is fairly straightforward, you use PHP to download a. Now that we have our base Drupal core in an extendable image, next we are going to install Composer. Next we’ll build our Dockerfile to add more goodies to this image.Ĭreate a new Dockerfile and use our new Drupal image drupal:8.7.5-apache in the FROM instruction: FROM drupal:8.7.5-apache This will be our starting point image as the Drupal team has done a good job keeping these images up to date on Docker Hub. I’m going to use the latest version of Drupal with the 8.7.5-apache tag to keep my version of Drupal consistant and to get the Apache version: Extending the Drupal Imageįirst, download the official Drupal container from Docker Hub. I’ll assume you have Docker installed are comfortable with creating new images with Dockerfiles and can launch images with Docker Compose. By extending the prebuilt Docker Hub Drupal we can start with a clean Drupal core, then extend to install Composer and Drush, install XDEBUG, and finally launch our container using Docker Compose. In this article I’m going to show how I setup a local Docker container running Drupal core to work on modules and other Drupal development tasks.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |