Skip to content

Docker dev-container image for Drupal development based of Microsoft PHP image

License

Notifications You must be signed in to change notification settings

alchatti/drupal-devcontainer-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development Container for Drupal

GitHub last commit Docker Pulls

Docker (tag) PHP (tag) NodeJS (tag) Drupal (tag) Ubuntu (tag) Apple silicon (tag) VS Code (tag)

Docker Stars Docker Image Size (tag) Docker Image Size (tag) Docker Image Size (tag)

Build & Publish Images Update Container Description

Drupal development container based on Microsoft PHP devcontainer image.

Usage

Devcontainer image is to be used for development inside a container. This image is loaded with the tools required to develop a Drupal & NodeJs project.

It can be used as standalone and it is recommended to use alchatti/drupal-devcontainer with VS Code for an interactive development experience with required extentions installed.

A base Drupal project is available at alchatti/drupal-devcontainer-sample-project

Dev feature are set for the container user vscode, a none root user provided by the Microsoft base image.

Apache server will start as part of the a startup script using command apache2ctl start

Xdebug port is 9003, the default client port.

Quick Start: Self contained Drupal site for testing & Demonstration

Drupal 10 can be installed with SQLite without the need for an additional database container.

For best Dev experience, start the container as vscode user. Hostname drupal-dev can be changed to any other name.

  1. To start a container in interactive mode and remove once exited, docker will auto create the volume drupal-dev-html to persist the site installation. type
docker run --rm -it \
-h "drupal-dev" \
-u "vscode" \
-p 80:80 \
-v "drupal-dev-html:/var/www/html" \
alchatti/drupal-devcontainer:8.1 fish
  1. Once the container finishes intializing visit http://localhost to show PHP information page.

  2. You can use init.sh command to create a new Drupal 10 site. Use SQLite as the database option for a self contained image. This script is based on Acquia configuration. You can also setup Drupal your self.

init.sh
  1. Once the Drupal is installed visit http://localhost, to start setting up Drupal.

  2. For demo purpose, select Demo: Umami Food Magazine (Experimental) as installation profile.

  3. For database use the SQLite and the Database file as default sites/default/files/.ht.sqlite.

  4. Configure the site by setting up the admin user name and password

  5. visit http://localhost to show the Drupal site.

  6. To exit the container and stop the service, type

exit
  • To delete the created volume and start fresh, type
docker volume rm drupal-dev-html

Additional usage options & flags

  • Change the shell to zsh and the theme to 'blue-owl' by using environment variable POSH_THEME_ENVIRONMENT, for more theme options check Oh My Posh theme.
docker run --rm -it \
-e POSH_THEME_ENVIRONMENT='blue-owl'
-h "drupal-dev" \
-u "vscode" \
-p 80:80 \
-v "drupal-dev-html:/var/www/html" \
alchatti/drupal-devcontainer:8.1 zsh

Tags

To target a specific version build the tag is configured as follow $php-$datetime

Available tags:

  • 8.2: PHP 8.2 with latest Node.js, and Composer at build.
  • 8.1: PHP 8.1 with latest Node.js, and Composer at build.

Legacy / Deprecated tags:

  • 7.4: PHP 7.4 with latest Node.js, and Composer at build. (last build 2023DEC01)

You can also use timestamped tags to target a specific build. Check https://hub.docker.com/r/alchatti/drupal-devcontainer/tags for available tags.

Image

The image is targeting the latest 8.1 & 8.2 versions of PHP with latest Node.js.

Scripts

# print image package versions/tags in json format
about | jq
# create a time stamped sql dump of the database using drush and store it under /var/www/html/dump
dump.sh
# Download latest acquia cloud database backup using acli
acli-dump.sh

Installed packages

The base image comes with Zsh, Apache, Xdebug, Composer.

With the following additional packages:

Environment variables

The following are environment variables for customization.

# ENV Defaults fpr APACHE
ENV APACHE_SERVER_NAME "localhost"
ENV APACHE_DOCUMENT_ROOT "docroot"
ENV WORKSPACE_ROOT "/var/www/html"
# ENV Default theme for Oh My Posh
ENV POSH_THEME_ENVIRONMENT "ys"

CI Build & Tagging

The process is automated using GitHub Actions workflow with two scripts:

  • build.sh: Builds the image based on PHP, Node, Sass version with the following arguments:

    • -p: PHP version or (7 & 8).
    • -n: Node.js version, node for latest, --lts for lts version.
  • test.sh: to load the latest local build image.

The workflow is set on schedule and triggered on push to the main branch. It also can be triggered manually from GitHub.

References

Change logs

January 2024

  • feat: base image updated to Debian 12 (Bookworm).
  • feat: fish now uses repository for installation.
  • feat: github/actions updated as follows:
    • actions/checkout@v2->4
    • docker/setup-qemu-action@v2->3
    • docker/setup-buildx-action@v2.0.0->3
    • docker/build-push-action@v3->5
  • ci: switch to peter-evans/dockerhub-description@v3 as it is being maintained.
  • fix: PassEnv APACHE_DOCUMENT_ROOT & WORKSPACE_ROOT in apache2.conf to enable in /etc/apache2/sites-available/*.conf

December 2023

  • feat: git-quick-stats added to the image.
  • feat: fish updated to 3.6.4-1.
  • feat: about script to prints base image OS version.
  • feat: retired 7.4 PHP version.

January 2023

  • feat: PHP 8.1 support and deprecated PHP 8.0
  • feat: Apple Silicon arm64 support for both PHP 8.1 and 7.4
  • feat: Drupal 10 support and updated the installation script.
  • feat: removed Drupal Console as it is deprecated.
  • feat: GitHub action workflow update to support multiple architecture, tag and push the image.
  • fix: fish with nvm.