diff --git a/CHANGELOG.md b/CHANGELOG.md index bb17cda..d65bb7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 4.2.2 - 2023/Jul/4 + +* Allow Docker Compose v2 + ### 4.2.1 - 2022/Oct/18 * Allow site-alias ^4 diff --git a/README.md b/README.md index a3a72e8..249ebc2 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ local: docker: service: drupal compose: + version: 1 options: --project dockerComposeProjectName --file docker-compose.yml --project-directory dockerComposeWorkDir exec: options: --user www-data @@ -78,7 +79,12 @@ docker-compose --project dockerComposeProjectName --file docker-compose.yml --pr `docker.project` and `compose.options --project` do the same thing, docker.project existed before options. -`docker.service` is the exact name of the service as it appears in docker-compos.yml +`docker.service` is the exact name of the service as it appears in docker-compose.yml + +`docker.compose.version` defaults to `1`. Set to `2` to use the new syntax: +``` +docker compose --project dockerComposeProjectName --file docker-compose.yml --project-directory dockerComposeWorkDir exec --user www-data -T drupal +``` Check the [docker-compose](https://docs.docker.com/compose/reference/overview/) manual for all available options. diff --git a/src/Transport/DockerComposeTransport.php b/src/Transport/DockerComposeTransport.php index c2c5376..cc723c5 100644 --- a/src/Transport/DockerComposeTransport.php +++ b/src/Transport/DockerComposeTransport.php @@ -61,7 +61,12 @@ public function addChdir($cd, $args) */ protected function getTransport() { - $transport = ['docker-compose']; + $version = $this->siteAlias->get('docker.compose.version', '1'); + if ($version == 2) { + $transport = ['docker', 'compose']; + } else { + $transport = ['docker-compose']; + } $project = $this->siteAlias->get('docker.project', ''); $options = $this->siteAlias->get('docker.compose.options', ''); if ($project && (strpos($options, '-p') === false || strpos($options, '--project') === false)) { diff --git a/tests/Transport/DockerComposeTransportTest.php b/tests/Transport/DockerComposeTransportTest.php index bf219a5..7c0e4e1 100644 --- a/tests/Transport/DockerComposeTransportTest.php +++ b/tests/Transport/DockerComposeTransportTest.php @@ -34,6 +34,28 @@ public function wrapTestValues() ] ], ], + [ + 'docker compose exec -T drupal ls', + [ + 'docker' => [ + 'service' => 'drupal', + 'compose' => [ + 'version' => '2', + ], + ] + ], + ], + [ + 'docker-compose exec -T drupal ls', + [ + 'docker' => [ + 'service' => 'drupal', + 'compose' => [ + 'version' => '1', + ] + ] + ], + ], [ 'docker-compose --project project2 --file myCompose.yml exec -T drupal ls', [