Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions php/class-ee-docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,19 @@ public static function docker_compose_down( $dir ) {
return false;
}

/**
* Check if a particular service exists in given docker-compose.yml.
*
* @param string $service Service whose availability needs to be checked.
* @param string $site_fs_path Path to the site root where docker-compose.yml file is present.
*
* @return bool Whether service is available or not.
*/
public static function service_exists( $service, $site_fs_path ) {
chdir( $site_fs_path );
$launch = EE::launch( 'docker-compose config --services' );
$services = explode( PHP_EOL, trim( $launch->stdout ) );

return in_array( $service, $services, true );
}
}