From 3cfac4ee56390adb1ed0251a4c85e8ec46402e68 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Wed, 30 Sep 2020 14:31:08 +0530 Subject: [PATCH 1/2] Add custom docker-compose support --- src/Service_Command.php | 9 +++++---- src/helper/service-utils.php | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Service_Command.php b/src/Service_Command.php index 4baeeeb..ec93648 100644 --- a/src/Service_Command.php +++ b/src/Service_Command.php @@ -1,6 +1,7 @@ filter_service( $args ); - EE::exec( "docker-compose stop $service", true, true ); + EE::exec( docker_compose_with_custom() . " stop $service", true, true ); EE::success( sprintf( 'Service %s disabled.', $service ) ); } @@ -157,11 +158,11 @@ public function disable( $args, $assoc_args ) { * * # Restart global service * $ ee service restart newrelic-daemon - * + * */ public function restart( $args, $assoc_args ) { $service = $this->filter_service( $args ); - EE::exec( "docker-compose restart $service", true, true ); + EE::exec( docker_compose_with_custom() . " restart $service", true, true ); EE::success( sprintf( 'Service %s restarted.', $service ) ); } @@ -192,7 +193,7 @@ public function reload( $args, $assoc_args ) { $service = $this->filter_service( $args ); $command = $this->service_reload_command( $service ); if ( $command ) { - EE::exec( "docker-compose exec $service $command", true, true ); + EE::exec( docker_compose_with_custom() . " exec $service $command", true, true ); EE::success( sprintf( 'Reloaded %s.', $service ) ); } else { EE::warning( "$service can not be reloaded." ); diff --git a/src/helper/service-utils.php b/src/helper/service-utils.php index df9bd42..729ace7 100644 --- a/src/helper/service-utils.php +++ b/src/helper/service-utils.php @@ -6,6 +6,7 @@ use EE\Model\Option; use Symfony\Component\Filesystem\Filesystem; use function EE\Site\Utils\sysctl_parameters; +use function EE\Utils\docker_compose_with_custom; /** * Boots up the container if it is stopped or not running. @@ -82,7 +83,7 @@ function init_global_container( $service, $container = '' ) { if ( IS_DARWIN && GLOBAL_DB === $service && ! $fs->exists( $db_conf_file ) ) { $fs->copy( SERVICE_TEMPLATE_ROOT . '/my.cnf.mustache', $db_conf_file ); } - \EE_DOCKER::boot_container( $container, 'docker-compose up -d ' . $service ); + \EE_DOCKER::boot_container( $container, docker_compose_with_custom() . ' up -d ' . $service ); return true; } else { return false; @@ -324,11 +325,11 @@ function set_nginx_proxy_version_conf() { chdir( EE_SERVICE_DIR ); $version_line = sprintf( 'add_header X-Powered-By \"EasyEngine v%s\";', EE_VERSION ); $version_file = '/version.conf'; - $version_success = EE::exec( sprintf( 'docker-compose exec global-nginx-proxy bash -c \'echo "%s" > %s\'', $version_line, $version_file ), false, false, [ + $version_success = EE::exec( sprintf( docker_compose_with_custom() . ' exec global-nginx-proxy bash -c \'echo "%s" > %s\'', $version_line, $version_file ), false, false, [ $version_file, $version_line, ] ); if ( $version_success ) { - EE::exec( 'docker-compose exec global-nginx-proxy bash -c "nginx -t && nginx -s reload"' ); + EE::exec( docker_compose_with_custom() . ' exec global-nginx-proxy bash -c "nginx -t && nginx -s reload"' ); } } From c077a911b8c527af0bb1a613865325e8ba19457e Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Tue, 27 Oct 2020 19:28:12 +0530 Subject: [PATCH 2/2] Move docker_compose_with_custom to class EE_DOCKER --- src/Service_Command.php | 9 +++------ src/helper/service-utils.php | 7 +++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Service_Command.php b/src/Service_Command.php index ec93648..ac01f23 100644 --- a/src/Service_Command.php +++ b/src/Service_Command.php @@ -1,8 +1,5 @@ filter_service( $args ); - EE::exec( docker_compose_with_custom() . " stop $service", true, true ); + EE::exec( \EE_DOCKER::docker_compose_with_custom() . " stop $service", true, true ); EE::success( sprintf( 'Service %s disabled.', $service ) ); } @@ -162,7 +159,7 @@ public function disable( $args, $assoc_args ) { */ public function restart( $args, $assoc_args ) { $service = $this->filter_service( $args ); - EE::exec( docker_compose_with_custom() . " restart $service", true, true ); + EE::exec( \EE_DOCKER::docker_compose_with_custom() . " restart $service", true, true ); EE::success( sprintf( 'Service %s restarted.', $service ) ); } @@ -193,7 +190,7 @@ public function reload( $args, $assoc_args ) { $service = $this->filter_service( $args ); $command = $this->service_reload_command( $service ); if ( $command ) { - EE::exec( docker_compose_with_custom() . " exec $service $command", true, true ); + EE::exec( \EE_DOCKER::docker_compose_with_custom() . " exec $service $command", true, true ); EE::success( sprintf( 'Reloaded %s.', $service ) ); } else { EE::warning( "$service can not be reloaded." ); diff --git a/src/helper/service-utils.php b/src/helper/service-utils.php index 729ace7..c028208 100644 --- a/src/helper/service-utils.php +++ b/src/helper/service-utils.php @@ -6,7 +6,6 @@ use EE\Model\Option; use Symfony\Component\Filesystem\Filesystem; use function EE\Site\Utils\sysctl_parameters; -use function EE\Utils\docker_compose_with_custom; /** * Boots up the container if it is stopped or not running. @@ -83,7 +82,7 @@ function init_global_container( $service, $container = '' ) { if ( IS_DARWIN && GLOBAL_DB === $service && ! $fs->exists( $db_conf_file ) ) { $fs->copy( SERVICE_TEMPLATE_ROOT . '/my.cnf.mustache', $db_conf_file ); } - \EE_DOCKER::boot_container( $container, docker_compose_with_custom() . ' up -d ' . $service ); + \EE_DOCKER::boot_container( $container, \EE_DOCKER::docker_compose_with_custom() . ' up -d ' . $service ); return true; } else { return false; @@ -325,11 +324,11 @@ function set_nginx_proxy_version_conf() { chdir( EE_SERVICE_DIR ); $version_line = sprintf( 'add_header X-Powered-By \"EasyEngine v%s\";', EE_VERSION ); $version_file = '/version.conf'; - $version_success = EE::exec( sprintf( docker_compose_with_custom() . ' exec global-nginx-proxy bash -c \'echo "%s" > %s\'', $version_line, $version_file ), false, false, [ + $version_success = EE::exec( sprintf( \EE_DOCKER::docker_compose_with_custom() . ' exec global-nginx-proxy bash -c \'echo "%s" > %s\'', $version_line, $version_file ), false, false, [ $version_file, $version_line, ] ); if ( $version_success ) { - EE::exec( docker_compose_with_custom() . ' exec global-nginx-proxy bash -c "nginx -t && nginx -s reload"' ); + EE::exec( \EE_DOCKER::docker_compose_with_custom() . ' exec global-nginx-proxy bash -c "nginx -t && nginx -s reload"' ); } }