Skip to content

Commit 84440ad

Browse files
Merge pull request #1246 from mrrobot47/update/docker_functions
Add docker-compose service check
2 parents b02faf4 + d0cc1e5 commit 84440ad

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

php/class-ee-docker.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,19 @@ public static function docker_compose_down( $dir ) {
199199
return false;
200200
}
201201

202+
/**
203+
* Check if a particular service exists in given docker-compose.yml.
204+
*
205+
* @param string $service Service whose availability needs to be checked.
206+
* @param string $site_fs_path Path to the site root where docker-compose.yml file is present.
207+
*
208+
* @return bool Whether service is available or not.
209+
*/
210+
public static function service_exists( $service, $site_fs_path ) {
211+
chdir( $site_fs_path );
212+
$launch = EE::launch( 'docker-compose config --services' );
213+
$services = explode( PHP_EOL, trim( $launch->stdout ) );
214+
215+
return in_array( $service, $services, true );
216+
}
202217
}

0 commit comments

Comments
 (0)