From d94ec0748a3edfef0feda7edf7b07ebe3e960a31 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Wed, 30 Sep 2020 14:44:12 +0530 Subject: [PATCH 1/2] Add custom docker-compose support --- src/Shell_Command.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 24873c6..22301d3 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -3,6 +3,7 @@ use EE\Model\Option; use Symfony\Component\Filesystem\Filesystem; use function EE\Site\Utils\auto_site_name; +use function EE\Utils\docker_compose_with_custom; use function EE\Utils\get_flag_value; use function EE\Site\Utils\get_site_info; @@ -105,9 +106,9 @@ public function __invoke( $args, $assoc_args ) { $tty = get_flag_value( $assoc_args, 'skip-tty' ) ? '-T' : ''; if ( $command ) { - EE::exec( "docker-compose exec $tty $user_string $service $shell -c \"$command\"", true, true, [], true ); + EE::exec( docker_compose_with_custom() . " exec $tty $user_string $service $shell -c \"$command\"", true, true, [], true ); } else { - $this->run( "docker-compose exec $user_string $service $shell" ); + $this->run( docker_compose_with_custom() . " exec $user_string $service $shell" ); } EE\Utils\delem_log( 'ee shell end' ); } @@ -146,7 +147,7 @@ private function run( $cmd, $descriptors = null ) { */ private function check_shell_available( $shell_container, $site ) { - $launch = EE::launch( 'docker-compose config --services' ); + $launch = EE::launch( docker_compose_with_custom() . ' config --services' ); $services = explode( PHP_EOL, trim( $launch->stdout ) ); if ( in_array( $shell_container, $services, true ) ) { return; @@ -165,7 +166,7 @@ private function check_shell_available( $shell_container, $site ) { * @return bool Success. */ private function check_user_available( $user, $shell_container ) { - $check_command = sprintf( "docker-compose exec --user='%s' %s bash -c 'exit'", $user, $shell_container ); + $check_command = sprintf( docker_compose_with_custom() . " exec --user='%s' %s bash -c 'exit'", $user, $shell_container ); if ( EE::exec( $check_command ) ) { return true; From 40a21a4c5aa096302579253cc08857089ec0f707 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Tue, 27 Oct 2020 19:28:13 +0530 Subject: [PATCH 2/2] Move docker_compose_with_custom to class EE_DOCKER --- src/Shell_Command.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 22301d3..069e746 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -3,7 +3,6 @@ use EE\Model\Option; use Symfony\Component\Filesystem\Filesystem; use function EE\Site\Utils\auto_site_name; -use function EE\Utils\docker_compose_with_custom; use function EE\Utils\get_flag_value; use function EE\Site\Utils\get_site_info; @@ -106,9 +105,9 @@ public function __invoke( $args, $assoc_args ) { $tty = get_flag_value( $assoc_args, 'skip-tty' ) ? '-T' : ''; if ( $command ) { - EE::exec( docker_compose_with_custom() . " exec $tty $user_string $service $shell -c \"$command\"", true, true, [], true ); + EE::exec( \EE_DOCKER::docker_compose_with_custom() . " exec $tty $user_string $service $shell -c \"$command\"", true, true, [], true ); } else { - $this->run( docker_compose_with_custom() . " exec $user_string $service $shell" ); + $this->run( \EE_DOCKER::docker_compose_with_custom() . " exec $user_string $service $shell" ); } EE\Utils\delem_log( 'ee shell end' ); } @@ -147,7 +146,7 @@ private function run( $cmd, $descriptors = null ) { */ private function check_shell_available( $shell_container, $site ) { - $launch = EE::launch( docker_compose_with_custom() . ' config --services' ); + $launch = EE::launch( \EE_DOCKER::docker_compose_with_custom() . ' config --services' ); $services = explode( PHP_EOL, trim( $launch->stdout ) ); if ( in_array( $shell_container, $services, true ) ) { return; @@ -166,7 +165,7 @@ private function check_shell_available( $shell_container, $site ) { * @return bool Success. */ private function check_user_available( $user, $shell_container ) { - $check_command = sprintf( docker_compose_with_custom() . " exec --user='%s' %s bash -c 'exit'", $user, $shell_container ); + $check_command = sprintf( \EE_DOCKER::docker_compose_with_custom() . " exec --user='%s' %s bash -c 'exit'", $user, $shell_container ); if ( EE::exec( $check_command ) ) { return true;