Git Product home page Git Product logo

deployable-contained-drupal's Introduction

Deployable Docker4Drupal

Problem: Need a Docker container for production desployments that is geared toward automated deployments and not local development.

Requirements

  • Nginx
  • PHP-FPM
  • Codebase in contain and not a volume
  • Mountable volume for user uploaded content
  • Template for dynamica creation of settings.php from ENV vars

There are a lot of Docker containers for Drupal, PHP, and Nginx; however, there seems to be none that fulfilled the requirements listed above hence this repository was born.

Build Enviornment Variables

We use GNU Make to assist in building the container. Why? Because a way was needed to handle Drupal source code before doing the Dockerbuild. Using GNU Make with Docker builds is a common pattern. Therefore, there are some requirements of the build environment that must be met in order to proceed.

Build Environment Requirements

  • GNU Make
  • PHP Composer

Maximum flexibility has been a goal of this project so a lot of variables can be customized in the build via build args. Whereever possible, the option has been provided to change download locations and to use alternate repositories such as a local cache. The Alpine APK repositories can be changed to use a local proxy/mirror. You can also alter the download location of the PHP binaries. Defaults are specified for all of these but you can choose to change them.

The Make process will pass the build arguements to the Docker process via envrionment variables.

Variable Value
ALPINE_VER Version of Alpine to use
NGINX_VER Nginx version
APK_MAIN URL to Main APK repo
APK_COMMUNITY URL to Community APK repo
APK_EDGE URL to Edge APK repo
PHP_URL URL to download PHP
PHP_ASC_URL URL to download PHP asc file
INSTALL_DRUPAL Install Drupal set to any value
APPSOURCE Path to your source code

Defaults are set for all variables, they are not required to build.

Drupal Installation

If INSTALL_DRUPAL variable is set, composer is used to create a blank Drupal project using the drupal/recommended-project process outlined on Drupal.org.

To deploy your own source code to this container set the variable APPSOURCE to the path of your Drupal8 code that follows the same pattern as the recommended-project (i.e. Drupal source is in a sub folder named "web"). Trailing slash is required at the end of the path.

If either of the above options are not provided then a generic html and php file is placed into the web director.

Runtime Environment Variables

Much of the environment inside the container can be controlled with run-time enviornment variables. Nginx, PHP, and Drupal have templates that are manipulated by environment varialbes. The templates are applied during the entry point of the container.

Variable Value
NGINX_MODSECURITY_ENABLED Enable Nginx Modsecurity
NGINX_MODSECURITY_USE_OWASP_CRS Enable Modsecurity OWASP core rule set
NGINX_VHOST_PRESET Set to Drupal version: drupal7 or drupal8
NGINX_DRUPAL_HIDE_HEADERS Hide headers for Drupal

Acknowledgement

A lot of the code here was borrowed from the Wodby project. They have some very well built base images that are highly configurable via environment files but their Nginx setup used PHP on a seperate container.

deployable-contained-drupal's People

Contributors

taz77 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.