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

Add docker version update migration #1780

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace EE\Migration;

use EE;
use EE\Migration\Base;

class CheckAndUpdateDocker extends Base {

/**
* Execute create table query for site and sitemeta table.
*
* @throws EE\ExitException
*/
public function up() {

EE::log( 'Checking Docker version.' );
$docker_version = 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.' );

// If it is MacOS, prompt user to update docker.
if ( 'Darwin' === PHP_OS ) {
EE::confirm( 'Do you want to update Docker?' );
EE::launch( 'open "docker://"' );
}

// If it is Linux, proceed with update.
if ( 'Linux' === PHP_OS ) {
EE::log( 'Updating Docker...' );
EE::launch( 'curl -fsSL https://get.docker.com | sh' );
}
}

// Check the version again post update.
$docker_version = 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.' );
}
}

/**
* Execute drop table query for site and sitemeta table.
*
* @throws EE\ExitException
*/
public function down() {

}
}