Skip to main content

Dev container

Eddy doesn't need a container: the build runs on the PHP, Composer and Node.js of your machine. A dev container gives you the same environment without installing them, in GitHub Codespaces, DevPod, VS Code or any other tool that reads .devcontainer/devcontainer.json. It also keeps an AI agent that works on the extension away from your machine. This page covers turning it on, what the container has and the traps it avoids.

Turn on the dev container​

The installer asks "Add a dev container", which defaults to no. With yes, the project gets .devcontainer/devcontainer.json. To add the file to a project you've already installed, ask the update skill to turn the dev container on (see Updating). The update skill keeps the file in every later update.

Eddy publishes 1 image for each PHP version that CI tests, for amd64 and arm64, with the PHP version in its name. The file names the image of the lowest PHP version that your Drupal majors support, the one the test-php-min-* jobs of .github/workflows/test.yml run. Its tag is the Eddy release that your project came from. So a Drupal 10 and 11 project installed from Eddy 5.3.0 starts ghcr.io/drevops/eddy-devcontainer-php8.3:5.3.0.

Each image has these tags:

TagImage
A release, such as 5.3.0The image that Eddy built for that release
latestThe image of the latest release that isn't a pre-release
canaryThe image built from the latest commit on the main branch of Eddy

A project installed from a clone of Eddy names the release that the clone names. To try the next release before it ships, put canary in .devcontainer/devcontainer.json by hand. Renovate moves a release tag to each later Eddy release with the same major version.

Start the container​

Run each of these from the root of your project. The tool builds nothing: it pulls the image and starts a container from it.

ToolStartGet a shellRemove
DevPoddevpod up . --ide nonedevpod ssh <name>devpod delete <name>
Dev Containers CLInpx @devcontainers/cli up --workspace-folder .npx @devcontainers/cli exec --workspace-folder . bashdocker rm -f the container it names
VS CodeThe Dev Containers: Reopen in Container commandIts terminalRemove Container in the Remote Explorer
Codespacesgh codespace create -R <owner>/<repository> -b <branch>gh codespace sshgh codespace delete

Codespaces builds the container from the branch on GitHub, so commit and push .devcontainer/devcontainer.json to that branch first.

Once the container starts, it runs scripts/eddy-tooling, so the tooling commands are ready. Then build the site as you would on your machine:

make build

The container has no copy of your git credentials. VS Code and Codespaces pass them in. With DevPod or the Dev Containers CLI, set up an SSH key or a credential helper in the container before you push.

What the container has​

  • PHP with Composer and the extensions that Drupal needs, gd, pdo_sqlite and sodium among them. It also has zip, which Composer unpacks packages with.
  • No PHP memory limit, as in CI, so PHPStan's workers have the memory they need.
  • pcov for code coverage, and Xdebug installed but off. XDEBUG=1 turns step debugging on, as it does on your machine (see Debug your extension).
  • Node.js 22 with npm, the version that CI runs.
  • Ahoy, for a project that uses Ahoy as its command wrapper.
  • Chromium and chromedriver for FunctionalJavascript tests. Chromium runs headless, since a container has no screen, and browser-start finds both on PATH.
  • sqlite3, the client that drush sql:cli runs, and make.
  • cloudflared, for the public tunnel.

Before Eddy publishes an image, CI checks each of these with goss, and that Chromium answers a WebDriver session.

The image sets LC_ALL=C.UTF-8, so a locale that your tool passes in from your machine, such as en_AU.UTF-8, prints no warning.

To add a PHP extension, run sudo docker-php-ext-install with its name. An extension that links to a system library needs that library's -dev package first. The image holds no package lists, so run sudo apt-get update before sudo apt-get install. The extension lasts until the container is removed, so add both commands to the postCreateCommand of your project to keep it.

Verify the image​

GitHub stores a signed build attestation for every published image. To verify the image that your project names, run this GitHub CLI command with the image and tag from .devcontainer/devcontainer.json:

gh attestation verify oci://ghcr.io/drevops/eddy-devcontainer-php8.3:5.3.0 --repo drevops/eddy

Reach the site​

start picks a free port from 8000 to 8099 (see Webserver), so the file labels that whole range. VS Code and Codespaces forward each port when start listens on it, and offer to open it. To forward a port by hand, add it in their Ports view. The Dev Containers CLI forwards no ports, so with the CLI, set CLOUDFLARE_TUNNEL=1 to reach the site (see Public tunnel). The image sets WEBSERVER_HOST=127.0.0.1: localhost is ::1 in the container, and a forwarded port connects to 127.0.0.1. The login links that provision and login print then open in your own browser.

The build directory​

build sits on a Docker volume rather than in your workspace, and so does the Rector cache in build/.rector. A volume is faster than a workspace that Docker Desktop shares from your machine, and file locks work on it (see Traps). assemble empties the volume in place of removing it. reset leaves the empty directory behind.

Docker creates the directory in your workspace for the volume. On a Linux machine, root owns that empty build directory outside the container, so remove it with sudo if you need to.

Traps​

A container avoids 3 traps that a development environment of your own can fall into:

  • A PHP without sodium. A PHP that a version manager such as mise or asdf compiles can leave out the sodium extension. composer require then fails on any package that requires ext-sodium, such as lcobucci/jwt, which Simple OAuth uses. The image has sodium. On your machine, install a PHP with it, rather than ignoring the platform requirement.
  • flock() does nothing on a shared workspace. On a workspace that Docker Desktop shares from your machine, flock() returns at once for a second process while the first still holds the lock. Rector's parallel workers then build the same cache files at once, and lint fails with errors such as Unable to create file or rename(...): No such file or directory in build/.rector. The dev container keeps build on a volume, where locks work. In a container of your own, do the same.
  • Git reports changes in a clean tree. A workspace that Docker Desktop shares doesn't keep the file stat data that git compares, so a rebase can stop on "Your local changes would be overwritten" while git status is clean. The image sets core.checkStat to minimal for every repository. In a container of your own, run git config core.checkStat minimal in the project.

A GitHub runner bind-mounts a normal Linux directory, where locks and stat data both work, so CI can't reproduce the last 2 traps.