Skip to content

Commit 26d85d9

Browse files
committed
Fix service list for custom compose
Signed-off-by: Riddhesh Sanghvi <[email protected]>
1 parent f0e4371 commit 26d85d9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

php/class-ee-docker.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ class EE_DOCKER {
1111
*
1212
* @return string
1313
*/
14-
public static function docker_compose_with_custom( array $files_before_custom = [] ): string {
14+
public static function docker_compose_with_custom( array $files_before_custom = [], bool $get_service = false ): string {
1515

1616
$fs = new Filesystem();
1717

18-
$command = 'docker-compose -f ';
18+
if ( $get_service ) {
19+
$command = 'docker-compose ';
20+
} else {
21+
$command = 'docker-compose -f docker-compose.yml ';
22+
}
1923

2024
$custom_compose = \EE::get_runner()->config['custom-compose'];
2125

@@ -27,13 +31,11 @@ public static function docker_compose_with_custom( array $files_before_custom =
2731
}
2832
}
2933
if ( $fs->exists( $custom_compose_path ) ) {
30-
$command .= $custom_compose_path;
34+
$command .= ' -f ' . $custom_compose_path;
3135
} else {
3236
EE::warning( 'File: ' . $custom_compose_path . ' does not exist. Falling back to default compose file.' );
33-
$command .= 'docker-compose.yml';
3437
}
3538
} else {
36-
$command .= 'docker-compose.yml';
3739

3840
if ( $fs->exists( SITE_CUSTOM_DOCKER_COMPOSE_DIR ) ) {
3941
$custom_compose_files = array_diff( scandir( SITE_CUSTOM_DOCKER_COMPOSE_DIR ), [ '.', '..' ] );
@@ -338,8 +340,9 @@ public static function get_services( $site_fs_path = '' ) {
338340
if ( ! empty( $site_fs_path ) ) {
339341
chdir( $site_fs_path );
340342
}
341-
$launch = EE::launch( \EE_DOCKER::docker_compose_with_custom() . ' config --services' );
342-
$services = explode( PHP_EOL, trim( $launch->stdout ) );
343+
$custom_service = empty( \EE::get_runner()->config['custom-compose'] ) ? false : true;
344+
$launch = EE::launch( \EE_DOCKER::docker_compose_with_custom( [], $custom_service ) . ' config --services' );
345+
$services = explode( PHP_EOL, trim( $launch->stdout ) );
343346

344347
return $services;
345348
}

0 commit comments

Comments
 (0)