@@ -8,14 +8,19 @@ class EE_DOCKER {
88 * Function to return docker-compose command with custom docker-compose files
99 *
1010 * @param array $files_before_custom Files to be included before custom compose file is included
11+ * @param bool $get_service Boolean to check if it is for getting service call or not.
1112 *
1213 * @return string
1314 */
14- public static function docker_compose_with_custom ( array $ files_before_custom = [] ): string {
15+ public static function docker_compose_with_custom ( array $ files_before_custom = [], bool $ get_service = false ): string {
1516
1617 $ fs = new Filesystem ();
1718
18- $ command = 'docker-compose -f ' ;
19+ if ( $ get_service ) {
20+ $ command = 'docker-compose ' ;
21+ } else {
22+ $ command = 'docker-compose -f docker-compose.yml ' ;
23+ }
1924
2025 $ custom_compose = \EE ::get_runner ()->config ['custom-compose ' ];
2126
@@ -27,13 +32,11 @@ public static function docker_compose_with_custom( array $files_before_custom =
2732 }
2833 }
2934 if ( $ fs ->exists ( $ custom_compose_path ) ) {
30- $ command .= $ custom_compose_path ;
35+ $ command .= ' -f ' . $ custom_compose_path ;
3136 } else {
3237 EE ::warning ( 'File: ' . $ custom_compose_path . ' does not exist. Falling back to default compose file. ' );
33- $ command .= 'docker-compose.yml ' ;
3438 }
3539 } else {
36- $ command .= 'docker-compose.yml ' ;
3740
3841 if ( $ fs ->exists ( SITE_CUSTOM_DOCKER_COMPOSE_DIR ) ) {
3942 $ custom_compose_files = array_diff ( scandir ( SITE_CUSTOM_DOCKER_COMPOSE_DIR ), [ '. ' , '.. ' ] );
@@ -338,8 +341,9 @@ public static function get_services( $site_fs_path = '' ) {
338341 if ( ! empty ( $ site_fs_path ) ) {
339342 chdir ( $ site_fs_path );
340343 }
341- $ launch = EE ::launch ( \EE_DOCKER ::docker_compose_with_custom () . ' config --services ' );
342- $ services = explode ( PHP_EOL , trim ( $ launch ->stdout ) );
344+ $ custom_service = empty ( \EE ::get_runner ()->config ['custom-compose ' ] ) ? false : true ;
345+ $ launch = EE ::launch ( \EE_DOCKER ::docker_compose_with_custom ( [], $ custom_service ) . ' config --services ' );
346+ $ services = explode ( PHP_EOL , trim ( $ launch ->stdout ) );
343347
344348 return $ services ;
345349 }
0 commit comments