Drupal development container based on Microsoft PHP devcontainer image.
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.
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.
- 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
-
Once the container finishes intializing visit http://localhost to show PHP information page.
-
You can use
init.sh
command to create a new Drupal 10 site. UseSQLite
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
-
Once the Drupal is installed visit http://localhost, to start setting up Drupal.
-
For demo purpose, select
Demo: Umami Food Magazine (Experimental)
as installation profile. -
For database use the
SQLite
and the Database file as defaultsites/default/files/.ht.sqlite
. -
Configure the site by setting up the
admin
user name and password -
visit http://localhost to show the Drupal site.
-
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
- Change the shell to
zsh
and the theme to 'blue-owl' by using environment variablePOSH_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
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.
The image is targeting the latest 8.1 & 8.2 versions of PHP with latest Node.js.
# 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
The base image comes with Zsh, Apache, Xdebug, Composer.
With the following additional packages:
-
Drupal dev tools
- Drush launcher.
- Drush 8 as global fallback and for Drupal 7.
- Drupal Coder
-
Acquia tools
- Acquia CLI requires PHP 8
- Acquia BLT launcher
-
Front-End development
-
Terminal enhancements:
- zsh-autosuggestions
- zsh-syntax-highlighting
- fish
- Oh My Posh for Zsh & Fish
-
Git enhancements:
- git-quick-stats a simple and efficient way to access various statistics in a git repository
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"
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.
- Docker Repo https://hub.docker.com/r/alchatti/drupal-devcontainer
- Image issues, details, source https://github.com/alchatti/drupal-devcontainer-image
- feat: base image updated to Debian 12 (Bookworm).
- feat:
fish
now uses repository for installation. - feat: github/actions updated as follows:
- actions/checkout@v
2
->4
- docker/setup-qemu-action@v
2
->3
- docker/setup-buildx-action@v
2.0.0
->3
- docker/build-push-action@v
3
->5
- actions/checkout@v
- 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
- feat:
git-quick-stats
added to the image. - feat:
fish
updated to3.6.4-1
. - feat:
about
script to prints base image OS version. - feat: retired
7.4
PHP version.
- 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
withnvm
.