diff --git a/src/helper/site-utils.php b/src/helper/site-utils.php index 9e02fe45..9ae480d3 100644 --- a/src/helper/site-utils.php +++ b/src/helper/site-utils.php @@ -100,71 +100,6 @@ function get_site_info( $args, $site_enabled_check = true, $exit_if_not_found = return $site_data; } - -/** - * Function to check all the required configurations needed to create the site. - * - * Boots up the container if it is stopped or not running. - */ -function init_checks() { - - $proxy_type = EE_PROXY_TYPE; - if ( 'running' !== EE::docker()::container_status( $proxy_type ) ) { - /** - * Checking ports. - */ - $port_80_status = \EE\Utils\get_curl_info( 'localhost', 80, true ); - $port_443_status = \EE\Utils\get_curl_info( 'localhost', 443, true ); - - // if any/both the port/s is/are occupied. - if ( ! ( $port_80_status && $port_443_status ) ) { - EE::error( 'Cannot create/start proxy container. Please make sure port 80 and 443 are free.' ); - } else { - - $fs = new Filesystem(); - - if ( ! $fs->exists( EE_CONF_ROOT . '/docker-compose.yml' ) ) { - generate_global_docker_compose_yml( $fs ); - } - - $EE_CONF_ROOT = EE_CONF_ROOT; - if ( ! EE::docker()::docker_network_exists( GLOBAL_BACKEND_NETWORK ) ) { - if ( ! EE::docker()::create_network( GLOBAL_BACKEND_NETWORK ) ) { - EE::error( 'Unable to create network ' . GLOBAL_BACKEND_NETWORK ); - } - } - if ( ! EE::docker()::docker_network_exists( GLOBAL_FRONTEND_NETWORK ) ) { - if ( ! EE::docker()::create_network( GLOBAL_FRONTEND_NETWORK ) ) { - EE::error( 'Unable to create network ' . GLOBAL_FRONTEND_NETWORK ); - } - } - if ( EE::docker()::docker_compose_up( EE_CONF_ROOT, [ 'nginx-proxy' ] ) ) { - $fs->dumpFile( "$EE_CONF_ROOT/nginx/conf.d/custom.conf", file_get_contents( EE_ROOT . '/templates/custom.conf.mustache' ) ); - EE::success( "$proxy_type container is up." ); - } else { - EE::error( "There was some error in starting $proxy_type container. Please check logs." ); - } - } - } -} - -/** - * Function to start global db if it is not running. - */ -function init_global_db() { - - if ( ! EE::docker()::docker_network_exists( GLOBAL_BACKEND_NETWORK ) ) { - if ( ! EE::docker()::create_network( GLOBAL_BACKEND_NETWORK ) ) { - EE::error( 'Unable to create network ' . GLOBAL_BACKEND_NETWORK ); - } - } - - if ( 'running' !== EE::docker()::container_status( GLOBAL_DB ) ) { - chdir( EE_CONF_ROOT ); - EE::docker()::boot_container( GLOBAL_DB, 'docker-compose up -d ' . GLOBAL_DB ); - } -} - /** * Generates global docker-compose.yml at EE_CONF_ROOT * diff --git a/src/site-type/html.php b/src/site-type/html.php index dd625c1a..41c801bc 100644 --- a/src/site-type/html.php +++ b/src/site-type/html.php @@ -107,7 +107,7 @@ public function create( $args, $assoc_args ) { $this->site_data['site_ssl_wildcard'] = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' ); $this->skip_status_check = \EE\Utils\get_flag_value( $assoc_args, 'skip-status-check' ); - \EE\Site\Utils\init_checks(); + \EE\Service\Utils\nginx_proxy_check(); \EE::log( 'Configuring project.' ); diff --git a/templates/global_docker_compose.yml.mustache b/templates/global_docker_compose.yml.mustache deleted file mode 100644 index 57e485d5..00000000 --- a/templates/global_docker_compose.yml.mustache +++ /dev/null @@ -1,57 +0,0 @@ -version: '3.5' - -services: - -{{#services}} - {{name}}: - container_name: {{container_name}} - image: {{image}} - {{#ports.0}} - ports: - {{#ports}} - - "{{.}}" - {{/ports}} - {{/ports.0}} - {{#depends_on}} - depends_on: - - {{.}} - {{/depends_on}} - {{#restart}} - restart: {{.}} - {{/restart}} - {{#command}} - command: {{.}} - {{/command}} - {{#labels.0}} - labels: - {{#labels}} - - "{{.}}" - {{/labels}} - {{/labels.0}} - {{#volumes.0}} - volumes: - {{#volumes}} - - "{{.}}" - {{/volumes}} - {{/volumes.0}} - {{#environment.0}} - environment: - {{#environment}} - - {{.}} - {{/environment}} - {{/environment.0}} - {{#networks.0}} - networks: - {{#networks}} - - {{.}} - {{/networks}} - {{/networks.0}} -{{/services}} - -networks: - global-frontend-network: - external: - name: ee-global-frontend-network - global-backend-network: - external: - name: ee-global-backend-network