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 support to independently version docker images #1166

Merged
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
11 changes: 11 additions & 0 deletions img-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"easyengine/cron": "v4.0.0-beta.5",
"easyengine/mailhog": "v4.0.0-beta.5",
"easyengine/mariadb": "v4.0.0-beta.5",
"easyengine/nginx-proxy": "v4.0.0-beta.5",
"easyengine/nginx": "v4.0.0-beta.5",
"easyengine/php": "v4.0.0-beta.5",
"easyengine/phpmyadmin": "v4.0.0-beta.5",
"easyengine/postfix": "v4.0.0-beta.5",
"easyengine/redis": "v4.0.0-beta.5"
}
20 changes: 11 additions & 9 deletions php/EE/Migration/Containers.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ public static function start_container_migration() {
* Pulls new images of all containers used by easyengine
*/
private static function pull_new_images() {
self::pull_or_error( 'easyengine/php', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/cron', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/redis', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/nginx', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/postfix', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/mailhog', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/mariadb', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/phpmyadmin', 'v' . EE_VERSION );
self::pull_or_error( 'easyengine/nginx-proxy', 'v' . EE_VERSION );

$img_versions = EE\Utils\get_image_versions();
self::pull_or_error( 'easyengine/php', $img_versions['easyengine/php'] );
self::pull_or_error( 'easyengine/cron', $img_versions['easyengine/cron'] );
self::pull_or_error( 'easyengine/redis', $img_versions['easyengine/redis'] );
self::pull_or_error( 'easyengine/nginx', $img_versions['easyengine/nginx'] );
self::pull_or_error( 'easyengine/postfix', $img_versions['easyengine/postfix'] );
self::pull_or_error( 'easyengine/mailhog', $img_versions['easyengine/mailhog'] );
self::pull_or_error( 'easyengine/mariadb', $img_versions['easyengine/mariadb'] );
self::pull_or_error( 'easyengine/phpmyadmin', $img_versions['easyengine/phpmyadmin'] );
self::pull_or_error( 'easyengine/nginx-proxy', $img_versions['easyengine/nginx-proxy'] );
}

/**
Expand Down
3 changes: 2 additions & 1 deletion php/site-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ function init_checks() {
EE::error( 'Cannot create/start proxy container. Please make sure port 80 and 443 are free.' );
} else {
$EE_CONF_ROOT = EE_CONF_ROOT;
$ee_proxy_command = "docker run --name $proxy_type -e LOCAL_USER_ID=`id -u` -e LOCAL_GROUP_ID=`id -g` --restart=always -d -p 80:80 -p 443:443 -v $EE_CONF_ROOT/nginx/certs:/etc/nginx/certs -v $EE_CONF_ROOT/nginx/dhparam:/etc/nginx/dhparam -v $EE_CONF_ROOT/nginx/conf.d:/etc/nginx/conf.d -v $EE_CONF_ROOT/nginx/htpasswd:/etc/nginx/htpasswd -v $EE_CONF_ROOT/nginx/vhost.d:/etc/nginx/vhost.d -v /var/run/docker.sock:/tmp/docker.sock:ro -v $EE_CONF_ROOT:/app/ee4 -v /usr/share/nginx/html easyengine/nginx-proxy:v" . EE_VERSION;
$img_versions = EE\Utils\get_image_versions();
$ee_proxy_command = "docker run --name $proxy_type -e LOCAL_USER_ID=`id -u` -e LOCAL_GROUP_ID=`id -g` --restart=always -d -p 80:80 -p 443:443 -v $EE_CONF_ROOT/nginx/certs:/etc/nginx/certs -v $EE_CONF_ROOT/nginx/dhparam:/etc/nginx/dhparam -v $EE_CONF_ROOT/nginx/conf.d:/etc/nginx/conf.d -v $EE_CONF_ROOT/nginx/htpasswd:/etc/nginx/htpasswd -v $EE_CONF_ROOT/nginx/vhost.d:/etc/nginx/vhost.d -v /var/run/docker.sock:/tmp/docker.sock:ro -v $EE_CONF_ROOT:/app/ee4 -v /usr/share/nginx/html easyengine/nginx-proxy:" . $img_versions['easyengine/nginx-proxy'];


if ( EE::docker()::boot_container( $proxy_type, $ee_proxy_command ) ) {
Expand Down
21 changes: 21 additions & 0 deletions php/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1545,3 +1545,24 @@ function get_callable_name( callable $callable ) {
return 'unknown';
}
}

/**
* Function to get the docker image versions stored in img-versions.json file.
*
* @return array Docker image versions.
*/
function get_image_versions() {

$img_version_file = file_get_contents( EE_ROOT . '/img-versions.json' );
if ( empty( $img_version_file ) ) {
EE::error( 'Image version file is empty. Can\'t proceed further.' );
}
$img_versions = json_decode( $img_version_file, true );
$json_error = json_last_error();
if ( $json_error != JSON_ERROR_NONE ) {
EE::debug( 'Json last error: ' . $json_error );
EE::error( 'Error decoding image version file.' );
}

return $img_versions;
}