Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docker Migration #1831

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use EE;
use EE\Migration\Base;
use Symfony\Component\Filesystem\Filesystem;

class CheckAndUpdateDockerOne extends Base {

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

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

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

EE::log( 'Checking docker-compose version' );
$docker_compose_version = trim( EE::launch( 'docker-compose version --short' )->stdout );
$docker_compose_path = EE::launch( 'command -v docker-compose' )->stdout;
$docker_compose_path = trim( $docker_compose_path );
$docker_compose_backup_path = EE_BACKUP_DIR . '/docker-compose.backup';
$fs = new Filesystem();
if ( ! $fs->exists( EE_BACKUP_DIR ) ) {
$fs->mkdir( EE_BACKUP_DIR );
}
$fs->copy( $docker_compose_path, $docker_compose_backup_path );

if ( version_compare( '1.29.2', $docker_compose_version, '>' ) ) {
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" );
}

// Check the version again post update.
$docker_version = EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout;
$docker_version = trim( EE::launch( 'docker version --format "{{.Server.Version}}"' )->stdout );
if ( version_compare( $docker_version, '20.10.10', '<' ) ) {
EE::error( 'Docker version should be 20.10.10 or above. Please update Docker and try again.' );
}

$docker_compose_version = trim( EE::launch( 'docker-compose version --short' )->stdout );
if ( version_compare( '1.29.2', $docker_compose_version, '!=' ) ) {
EE::error( 'Docker-compose version should be 1.29.2. Please update Docker-compose and try again.' );
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions php/EE/Migration/Containers.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static function image_cleanup() {
}

/**
* Update docker-compose to v2.26.1 if lower version is installed.
* Update docker-compose to v2.27.0 if lower version is installed.
*/
public static function update_docker_compose() {

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

if ( version_compare( '2.26.1', $docker_compose_version, '>' ) ) {
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" );
if ( version_compare( '2.27.0', $docker_compose_version, '>' ) ) {
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" );
}
}

Expand Down
6 changes: 3 additions & 3 deletions php/EE/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public function check_requirements( $show_error = true ) {
$error[] = 'EasyEngine requires docker-compose.';
}

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