Skip to content

Commit b70546e

Browse files
committed
Merge branch 'develop' for v4.0.8
2 parents 892e70e + 8df294f commit b70546e

File tree

7 files changed

+184
-45
lines changed

7 files changed

+184
-45
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.7
1+
4.0.8

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"easyengine/cron-command": "v1.0.1",
3434
"easyengine/log-command": "v1.0.0",
3535
"easyengine/mailhog-command": "v1.0.1",
36-
"easyengine/site-command": "v2.2.8",
37-
"easyengine/site-type-wp": "v1.0.5",
38-
"easyengine/site-type-php": "v1.0.5",
39-
"easyengine/service-command": "v1.0.5",
36+
"easyengine/site-command": "v2.2.9",
37+
"easyengine/site-type-wp": "v1.0.6",
38+
"easyengine/site-type-php": "v1.0.6",
39+
"easyengine/service-command": "v1.0.6",
4040
"easyengine/shell-command" : "v1.0.1",
4141
"justinrainbow/json-schema": "5.2.7",
4242
"monolog/monolog": "1.24.0",

composer.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

php/EE/Migration/Containers.php

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ private static function migrate_global_containers( $updated_images ) {
156156
[ $global_compose_file_backup_path, $global_compose_file_path, $updated_global_images ]
157157
);
158158

159+
/**
160+
* Create support containers.
161+
*/
162+
self::$rsp->add_step(
163+
'create-support-global-containers',
164+
'EE\Migration\GlobalContainers::enable_support_containers',
165+
'EE\Migration\GlobalContainers::disable_support_containers',
166+
null,
167+
null
168+
);
169+
159170
self::$rsp->add_step(
160171
'stop-global-containers',
161172
'EE\Migration\GlobalContainers::down_global_containers',
@@ -175,7 +186,8 @@ private static function migrate_global_containers( $updated_images ) {
175186
$all_global_images = GlobalContainers::get_all_global_images_with_service_name();
176187
foreach ( $updated_global_images as $image_name ) {
177188
$global_container_name = $all_global_images[ $image_name ];
178-
$global_service_name = ltrim( $global_container_name, 'ee-' );
189+
$global_service_name = ltrim( $global_container_name, 'services_' );
190+
$global_service_name = rtrim( $global_service_name, '_1' );
179191
self::$rsp->add_step(
180192
"upgrade-$global_container_name-container",
181193
"EE\Migration\GlobalContainers::global_service_up",
@@ -184,6 +196,17 @@ private static function migrate_global_containers( $updated_images ) {
184196
[ $global_service_name ]
185197
);
186198
}
199+
200+
/**
201+
* Remove support containers.
202+
*/
203+
self::$rsp->add_step(
204+
'remove-support-global-containers',
205+
'EE\Migration\GlobalContainers::disable_support_containers',
206+
'EE\Migration\GlobalContainers::enable_support_containers',
207+
null,
208+
null
209+
);
187210
}
188211

189212
/**
@@ -210,11 +233,23 @@ public static function migrate_site_containers( $updated_images ) {
210233
$ee_site_object = SiteContainers::get_site_object( $site['site_type'] );
211234

212235
if ( $site['site_enabled'] ) {
236+
237+
/**
238+
* Enable support containers.
239+
*/
240+
self::$rsp->add_step(
241+
sprintf( 'enable-support-containers-%s', $site['site_url'] ),
242+
'EE\Migration\SiteContainers::enable_support_containers',
243+
'EE\Migration\SiteContainers::disable_support_containers',
244+
[ $site['site_url'], $site['site_fs_path'] ],
245+
[ $site['site_url'], $site['site_fs_path'] ]
246+
);
247+
213248
self::$rsp->add_step(
214249
"disable-${site['site_url']}-containers",
215-
'EE\Migration\SiteContainers::disable_site',
216-
'EE\Migration\SiteContainers::enable_site',
217-
[ $site, $ee_site_object ],
250+
'EE\Migration\SiteContainers::disable_default_containers',
251+
'EE\Migration\SiteContainers::enable_default_containers',
252+
[ $site ],
218253
[ $site, $ee_site_object ]
219254
);
220255
}
@@ -238,11 +273,22 @@ public static function migrate_site_containers( $updated_images ) {
238273
if ( $site['site_enabled'] ) {
239274
self::$rsp->add_step(
240275
"upgrade-${site['site_url']}-containers",
241-
'EE\Migration\SiteContainers::enable_site',
242-
'EE\Migration\SiteContainers::enable_site',
276+
'EE\Migration\SiteContainers::enable_default_containers',
277+
'EE\Migration\SiteContainers::enable_default_containers',
243278
[ $site, $ee_site_object ],
244279
[ $site, $ee_site_object ]
245280
);
281+
282+
/**
283+
* Disable support containers.
284+
*/
285+
self::$rsp->add_step(
286+
sprintf( 'disable-support-containers-%s', $site['site_url'] ),
287+
'EE\Migration\SiteContainers::disable_support_containers',
288+
'EE\Migration\SiteContainers::enable_support_containers',
289+
[ $site['site_url'], $site['site_fs_path'] ],
290+
[ $site['site_url'], $site['site_fs_path'] ]
291+
);
246292
}
247293
}
248294
}

php/EE/Migration/GlobalContainers.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace EE\Migration;
44

55
use EE;
6+
use Symfony\Component\Filesystem\Filesystem;
67

78
/**
89
* Upgrade existing global containers to new docker-image
@@ -43,7 +44,7 @@ public static function revert_global_containers( $source_path, $dest_path, $upda
4344
$all_global_images = self::get_all_global_images_with_service_name();
4445
foreach ( $updated_images as $image_name ) {
4546
$global_container_name = $all_global_images[ $image_name ];
46-
$services_to_regenerate .= str_replace( '-', '_', ltrim( $global_container_name, 'ee-' ) ) . ' ';
47+
$services_to_regenerate .= ltrim( rtrim( $global_container_name, '_1' ), 'services_' ) . ' ';
4748
}
4849
if ( empty( trim( $services_to_regenerate ) ) ) {
4950
return;
@@ -74,7 +75,8 @@ public static function down_global_containers( $updated_images ) {
7475

7576
foreach ( $updated_images as $image_name ) {
7677
$global_container_name = $all_global_images[ $image_name ];
77-
$global_service_name = ltrim( $global_container_name, 'ee-' );
78+
$global_service_name = ltrim( $global_container_name, 'services_' );
79+
$global_service_name = rtrim( $global_service_name, '_1' );
7880
EE::debug( "Removing $global_container_name" );
7981

8082
if ( false !== \EE_DOCKER::container_status( $global_container_name ) ) {
@@ -129,4 +131,32 @@ public static function get_all_global_images_with_service_name() {
129131
// 'easyengine/cron' => EE_CRON_SCHEDULER, //TODO: Add it to global docker-compose.
130132
];
131133
}
134+
135+
/**
136+
* Create support containers for global-db and global-redis service.
137+
*/
138+
public static function enable_support_containers() {
139+
if ( ! chdir( EE_SERVICE_DIR ) ) {
140+
throw new \Exception( sprintf( '%s path does not exist', EE_SERVICE_DIR ) );
141+
}
142+
143+
$command = 'docker-compose --project-name=ee up -d global-db global-redis';
144+
if ( ! EE::exec( $command ) ) {
145+
throw new \Exception( 'Unable to create support container.' );
146+
}
147+
}
148+
149+
/**
150+
* Remove support containers for global-db and global-redis service.
151+
*/
152+
public static function disable_support_containers() {
153+
if ( ! chdir( EE_SERVICE_DIR ) ) {
154+
throw new \Exception( sprintf( '%s path does not exist', EE_SERVICE_DIR ) );
155+
}
156+
157+
$command = 'docker-compose --project-name=ee down';
158+
if ( ! EE::exec( $command ) ) {
159+
throw new \Exception( 'Unable to remove support container.' );
160+
}
161+
}
132162
}

0 commit comments

Comments
 (0)