DevOps
Phase2
February 20, 2018
Whatever your standard environment setup, it is inevitable that each project brings some new wrinkle. Outrigger's Docker image library endeavors to make the most common variations of your environment configuration really easy to adjust. Without building a custom Docker image or overriding your configuration files, our images can be tweaked for your most typical needs.
You may be wondering, "Why do we need to discuss templating and container details as soon as something common needs to change. Are containers too much for my needs?" You are not alone in wondering that.
The short answer is that these extra steps ensure that:
Templating is for combining content and HTML markup, right? That's the standard use around web development, but the infrastructure automation world has been using templating for years, in many different ways, for the same reasons: capturing business logic in a testable, versionable manner separate from the specific ways that logic might be needed. It is a key mechanism for reuse.
There are many tools that can help us with environment templating; however, confd is our favorite as a lightweight tool that works well in the stripped-down space of a Docker container. It uses templates written in Golang's native templating language and can take environment variables to dynamically populate that template and position the resulting configuration file when your container is started.
This templating can be used to create or modify any file inside the Docker image, and the simple environment control mechanism makes it really simple to configure via docker run or docker-compose configurations.
If you are using Outrigger to facilitate Drupal development, you are very likely to be using Redis, MariaDB, and Apache w/ PHP-FPM from the Outrigger image library. Each of these has at least one configuration option via templated environment variables. They can be seen in each image README on Docker Hub or GitHub:
Other images also have these kinds of environment settings, they are documented in the image README when present.
None of these tunable settings require you to take an explicit action. All of them have sane defaults that we have found are effective for most projects. However, if you need to override these settings, simply use the standard techniques for injecting environment variables into Docker containers.
Run the following command to open a BASH session in the outrigger/build container, with Xdebug active for CLI troubleshooting.
[bash]docker run --rm -it -e "PHP_XDEBUG='true'" outrigger/build bash[/bash]
Use a docker-compose.yml configuration like the following to spin up a database for your project.
[yaml]
version: '3.3'
services:
db:
image: outrigger/mariadb:10.2
environment:
# HERE ARE THE DATABASE CONFIGURATION PROPERTIES
MYSQL_DATABASE: projectname_drupal
MYSQL_SLOW_QUERY_LOG: 1
# For the sake of completeness, here's how to wire up this test database to Outrigger's DNS
system.
network_mode: bridge
labels:
com.dnsdock.name: db
com.dnsdock.image: projectname
[/yaml]
Once in place, you can spin up a new database with docker-compose up.
In future posts we will dive deeper into what you can do when these common customizations don't handle your needs, as well as how to build and contribute to Docker images using these tools.