Skip to content

Commit e75ecaf

Browse files
authored
Merge pull request #1831 from mrrobot47/update/docker-migration1
Update Docker Migration
2 parents 04fb9c9 + 36f61eb commit e75ecaf

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

migrations/db/20240502102550_easyengine_check_and_update_docker_one.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use EE;
66
use EE\Migration\Base;
7+
use Symfony\Component\Filesystem\Filesystem;
78

89
class CheckAndUpdateDockerOne extends Base {
910

@@ -15,7 +16,7 @@ class CheckAndUpdateDockerOne extends Base {
1516
public function up() {
1617

1718
EE::log( 'Checking Docker version.' );
18-
$docker_version = EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout;
19+
$docker_version = trim( EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout );
1920

2021
if ( version_compare( $docker_version, '20.10.10', '<' ) ) {
2122
EE::warning( 'Docker version should be 20.10.10 or above.' );
@@ -33,11 +34,31 @@ public function up() {
3334
}
3435
}
3536

37+
EE::log( 'Checking docker-compose version' );
38+
$docker_compose_version = trim( EE::launch( 'docker-compose version --short' )->stdout );
39+
$docker_compose_path = EE::launch( 'command -v docker-compose' )->stdout;
40+
$docker_compose_path = trim( $docker_compose_path );
41+
$docker_compose_backup_path = EE_BACKUP_DIR . '/docker-compose.backup';
42+
$fs = new Filesystem();
43+
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
44+
$fs->mkdir( EE_BACKUP_DIR );
45+
}
46+
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
47+
48+
if ( version_compare( '1.29.2', $docker_compose_version, '>' ) ) {
49+
EE::exec( "curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
50+
}
51+
3652
// Check the version again post update.
37-
$docker_version = EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout;
53+
$docker_version = trim( EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout );
3854
if ( version_compare( $docker_version, '20.10.10', '<' ) ) {
3955
EE::error( 'Docker version should be 20.10.10 or above. Please update Docker and try again.' );
4056
}
57+
58+
$docker_compose_version = trim( EE::launch( 'docker-compose version --short' )->stdout );
59+
if ( version_compare( '1.29.2', $docker_compose_version, '!=' ) ) {
60+
EE::error( 'Docker-compose version should be 1.29.2. Please update Docker-compose and try again.' );
61+
}
4162
}
4263

4364
/**

php/EE/Migration/Containers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static function image_cleanup() {
123123
}
124124

125125
/**
126-
* Update docker-compose to v2.26.1 if lower version is installed.
126+
* Update docker-compose to v2.27.0 if lower version is installed.
127127
*/
128128
public static function update_docker_compose() {
129129

@@ -137,8 +137,8 @@ public static function update_docker_compose() {
137137
}
138138
$fs->copy( $docker_compose_path, $docker_compose_backup_path );
139139

140-
if ( version_compare( '2.26.1', $docker_compose_version, '>' ) ) {
141-
EE::exec( "curl -L https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
140+
if ( version_compare( '2.27.0', $docker_compose_version, '>' ) ) {
141+
EE::exec( "curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o $docker_compose_path && chmod +x $docker_compose_path" );
142142
}
143143
}
144144

php/EE/Runner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ public function check_requirements( $show_error = true ) {
105105
$error[] = 'EasyEngine requires docker-compose.';
106106
}
107107

108-
$docker_compose_version = EE::launch( 'docker-compose version --short' )->stdout;
109-
if ( version_compare( $docker_compose_version, '2.26.0', '<' ) ) {
108+
$docker_compose_version = trim( EE::launch( 'docker-compose version --short' )->stdout );
109+
if ( version_compare( $docker_compose_version, '2.26.1', '<' ) ) {
110110
if ( $show_error ) {
111-
EE::warning( 'EasyEngine requires docker-compose version 2.26.0 or greater.' );
111+
EE::warning( 'EasyEngine requires docker-compose version 2.26.1 or greater.' );
112112
EE::warning( 'You can get the updated version of docker-compose from assets in https://github.com/docker/compose/releases/tag/v2.26.1' );
113113
}
114114
}

0 commit comments

Comments
 (0)