From 11787a1f9a04ff8d159d4c606641296797934203 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Sun, 24 Mar 2024 11:35:46 -0300 Subject: [PATCH] Pull docker images and inform user --- .../Environment/Environments/Environment.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/src/Environment/Environments/Environment.php b/src/src/Environment/Environments/Environment.php index ae143fcf..8bdb6f2b 100644 --- a/src/src/Environment/Environments/Environment.php +++ b/src/src/Environment/Environments/Environment.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; +use function QIT_CLI\is_ci; use function QIT_CLI\is_windows; use function QIT_CLI\normalize_path; use function QIT_CLI\use_tty; @@ -241,6 +242,22 @@ protected function generate_docker_compose(): void { protected function up_docker_compose(): void { $this->add_container_names(); + if ( empty( $this->cache->get( 'qit_env_up_first_run' ) ) && ! is_ci() ) { + $this->cache->set( 'qit_env_up_first_run', '1', - 1 ); + $this->output->writeln( 'First-time setup is pulling Docker images and caching downloads. Subsequent runs will be faster.' ); + } + + // Do a docker compose pull first, to make sure images are updated. + $pull_process = new Process( array_merge( $this->docker->find_docker_compose(), [ '-f', $this->env_info->temporary_env . '/docker-compose.yml', 'pull' ] ) ); + $pull_process->setTimeout( 600 ); + $pull_process->setIdleTimeout( 600 ); + $pull_process->setPty( use_tty() ); + $pull_process->run( function ( $type, $buffer ) { + if ( $this->output->isVerbose() ) { + $this->output->write( $buffer ); + } + } ); + $args = array_merge( $this->docker->find_docker_compose(), [ '-f', $this->env_info->temporary_env . '/docker-compose.yml', 'up', '-d' ] ); $up_process = new Process( $args );