Skip to content

Commit

Permalink
Merge pull request #219 from woocommerce/24-11/docker-compose-not-found
Browse files Browse the repository at this point in the history
Fix "docker compose not found"
  • Loading branch information
Luc45 authored Nov 13, 2024
2 parents a68a89b + a7e4472 commit 8ab61dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Binary file modified qit
Binary file not shown.
20 changes: 12 additions & 8 deletions src/src/Environment/Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,21 @@ public static function should_set_user(): bool {
* @return array<string> The docker-compose command to use, in a Symfony Process format.
*/
public function find_docker_compose(): array {
// Find out if it's docker-compose (v1) or docker compose (v2).
$v1_version = trim( shell_exec( 'docker-compose --version' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec
$v2_version = trim( shell_exec( 'docker compose --version' ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec
$output = [];
$return_var = 0;

if ( $v1_version ) {
return [ 'docker-compose' ];
} elseif ( $v2_version ) {
// Prefer Docker Compose v2 over v1.
exec( 'docker compose version >/dev/null 2>&1', $output, $return_var );
if ( $return_var === 0 ) {
return [ 'docker', 'compose' ];
} else {
throw new \RuntimeException( 'Could not find docker-compose or docker compose' );
}

exec( 'docker-compose version >/dev/null 2>&1', $output, $return_var );
if ( $return_var === 0 ) {
return [ 'docker-compose' ];
}

throw new \RuntimeException( 'Could not find docker compose or docker-compose' );
}

public function maybe_pull_docker_compose( string $docker_compose_path, string $environment_type ): void {
Expand Down

0 comments on commit 8ab61dd

Please sign in to comment.