diff --git a/README.md b/README.md index d2aaefd0..1c03afd6 100644 --- a/README.md +++ b/README.md @@ -442,7 +442,7 @@ include which will give you helpers that you can include and reference for tasks such as setting up [Terminus](https://pantheon.io/docs/terminus). See [scaffold/gitlab/Pantheon.gitlab-ci.yml](scaffold/gitlab/Pantheon.gitlab-ci.yml). -### Tugboat +## Tugboat Add the following to `composer.json` to add Tugboat configuration: @@ -450,13 +450,13 @@ Add the following to `composer.json` to add Tugboat configuration: { "extra": { "drainpipe": { - "tugboat": { - "provider": "pantheon" - } + "tugboat": {} } } } ``` - -The PHP and database version is autodetected based on your `pantheon.yml`, with -the nodejs version being derived from DDEV settings. +The following will be autodetected based on your `.ddev/config.yml`: +- PHP version +- Database type and version +- nodejs version +- Redis (Obtained with `ddev get ddev/ddev-redis`) diff --git a/scaffold/tugboat/config.yml.twig b/scaffold/tugboat/config.yml.twig index b20fd502..5fe5fbf0 100644 --- a/scaffold/tugboat/config.yml.twig +++ b/scaffold/tugboat/config.yml.twig @@ -1,7 +1,7 @@ services: php: http: false - image: tugboatqa/php-nginx:{{ php_version }}-fpm + image: tugboatqa/{{ webserver_image }}:{{ php_version }}-fpm default: true depends: diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index b600e4a8..aa081fd5 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -278,10 +278,11 @@ private function installCICommands(): void } // Tugboat - if (!empty($this->extra['drainpipe']['tugboat']['host'])) { + if (isset($this->extra['drainpipe']['tugboat'])) { $fs->removeDirectory('./.tugboat'); $tugboatConfig = [ 'nodejs_version' => '18', + 'webserver_image' => 'php-nginx', 'database_type' => 'mariadb', 'database_version' => '10.6', 'php_version' => '8.1', @@ -289,24 +290,24 @@ private function installCICommands(): void if (file_exists('./.ddev/config.yml')) { $ddevConfig = Yaml::parseFile('./.ddev/config.yml'); + $tugboatConfig = [ + 'database_type' => $ddevConfig['database']['type'], + 'database_version' => $ddevConfig['database']['version'], + 'php_version' => $ddevConfig['php_version'], + ]; if (!empty($ddevConfig['nodejs_version'])) { $tugboatConfig['nodejs_version'] = $ddevConfig['nodejs_version']; } + if (!empty($ddevConfig['webserver_type']) && $ddevConfig['webserver_type'] === 'apache-fpm') { + $tugboatConfig['webserver_image'] = 'php'; + } } - // Pantheon - if ($this->extra['drainpipe']['tugboat']['host'] === 'pantheon') { - $pantheonConfig = Yaml::parseFile('./pantheon.yml'); - $composerJson = file_get_contents('composer.json'); - $composerFullConfig = json_decode($composerJson, true); - - $tugboatConfig['php_version'] = $pantheonConfig['php_version']; - $tugboatConfig['database_version'] = $pantheonConfig['database']['version']; - - if (is_array($composerFullConfig['require']) && in_array('drupal/redis', array_keys($composerFullConfig['require']))) { - $tugboatConfig['memory_cache_type'] = 'redis'; - $tugboatConfig['memory_cache_version'] = 7; - } + if (file_exists('./.ddev/docker-compose.redis.yaml')) { + $redisConfig = Yaml::parseFile('.ddev/docker-compose.redis.yaml'); + $redisImage = explode(':', $redisConfig['services']['redis']['image']); + $tugboatConfig['memory_cache_type'] = 'redis'; + $tugboatConfig['memory_cache_version'] = array_pop($redisImage); } if (count($tugboatConfig) > 0) {