Problem/Motivation

Our dev and production environments use Docker containers to serve sites. These are relatively easy to change, to swap out PHP versions -- but one of the main benefits of Drupal Flake is to be able to easily switch the PHP version for drush, dr, composer, etc - the shell/command line environment.

We want to use the Nix php environment in the shell, without putting the rest of the environment at risk by accidentally starting it up.

Steps to reproduce

Load a site with Drupal Flake into a traditional web server, or one using Docker containers.

Run start-detached or start.

Now you get process-compose starting up database, php, and nginx servers, and the flake systems take over, breaking your dev or production site!

Proposed resolution

Put in a guard to prevent this from accidentally happening -- when the env var DRUPAL_FLAKE_SERVICES_DISABLED=1 is set, make the various start scripts exit without starting services.

The rest of the Flake scripts and CLI/shell programs continue to function as normal.

Remaining tasks

User interface changes

API changes

New environment variable that can be set to prevent accidental service starts.

Data model changes

Comments

freelock created an issue. See original summary.

  • freelock committed 329b8db8 on 1.0.x
    feat: #3619762 Add a service guard to prevent accidentally starting...
freelock’s picture

Status: Active » Needs review

Added to main dev branch, not yet tested.

freelock’s picture

Implemented the Drupal-flake kill switch using:

DRUPAL_FLAKE_SERVICES_DISABLED=1

No NixOS management is required; it works on Ubuntu through the normal process environment.

Behavior

With the variable enabled, Drupal-flake still provides:

  • PHP
  • Composer
  • Drush
  • PHPUnit and development tools
  • `setup-drupal`
  • `setup-settings`
  • `nix-settings`
  • Other non-service CLI commands

These service-start paths are blocked:

start
start-detached
start-demo
start-config
demo
nix run
nix run .#detached
nix run .#demo
nix run .#config

Automatic browser opening is also disabled.

A blocked command reports:

Error: drupal-flake service startup is disabled in this environment.

The shell displays:

CLI-only mode: drupal-flake service startup is disabled.

Ubuntu configuration

For SSH and other PAM login sessions, add this to `/etc/environment`:

DRUPAL_FLAKE_SERVICES_DISABLED=1

Then log out and reconnect. Existing sessions will not automatically receive the new value.

CLI tools should continue working:

php --version
composer --version
drush status
freelock’s picture

Status: Needs review » Fixed

Confirmed working. Easiest way to set this is to add DRUPAL_FLAKE_SERVICES_DISABLED=1 to /etc/environment and then log in again.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.