Skip to content

Commit

Permalink
Allow local images
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron committed Nov 30, 2024
1 parent af67b2c commit 931e623
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -1491,25 +1491,30 @@ function (string $runtimeId, ?string $payload, string $path, string $method, mix
*/
$allowList = empty(Http::getEnv('OPR_EXECUTOR_RUNTIMES')) ? [] : \explode(',', Http::getEnv('OPR_EXECUTOR_RUNTIMES'));

$runtimeVersions = \explode(',', Http::getEnv('OPR_EXECUTOR_RUNTIME_VERSIONS', 'v4') ?? 'v4');
foreach ($runtimeVersions as $runtimeVersion) {
Console::success("Pulling $runtimeVersion images...");
$runtimes = new Runtimes($runtimeVersion); // TODO: @Meldiron Make part of open runtimes
$runtimes = $runtimes->getAll(true, $allowList);
$callables = [];
foreach ($runtimes as $runtime) {
$callables[] = function () use ($runtime, $orchestration) {
Console::log('Warming up ' . $runtime['name'] . ' ' . $runtime['version'] . ' environment...');
$response = $orchestration->pull($runtime['image']);
if ($response) {
Console::info("Successfully Warmed up {$runtime['name']} {$runtime['version']}!");
} else {
Console::warning("Failed to Warmup {$runtime['name']} {$runtime['version']}!");
}
};
}
if(Http::isDevelopment()) {
// Useful to prevent auto-pulling from remote when testing local images
Console::info("Skipping image pulling in development mode.");
} else {
$runtimeVersions = \explode(',', Http::getEnv('OPR_EXECUTOR_RUNTIME_VERSIONS', 'v4') ?? 'v4');
foreach ($runtimeVersions as $runtimeVersion) {
Console::success("Pulling $runtimeVersion images...");
$runtimes = new Runtimes($runtimeVersion); // TODO: @Meldiron Make part of open runtimes
$runtimes = $runtimes->getAll(true, $allowList);
$callables = [];
foreach ($runtimes as $runtime) {
$callables[] = function () use ($runtime, $orchestration) {
Console::log('Warming up ' . $runtime['name'] . ' ' . $runtime['version'] . ' environment...');
$response = $orchestration->pull($runtime['image']);
if ($response) {
Console::info("Successfully Warmed up {$runtime['name']} {$runtime['version']}!");
} else {
Console::warning("Failed to Warmup {$runtime['name']} {$runtime['version']}!");
}
};
}

batch($callables);
batch($callables);
}
}

Console::success("Image pulling finished.");
Expand Down

0 comments on commit 931e623

Please sign in to comment.