Skip to content

Commit e79042b

Browse files
Merge pull request #38 from open-runtimes/feat-multiversion-pull
Feat: Multiversion pull for images
2 parents 85a715d + c4c9e86 commit e79042b

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ OPR_EXECUTOR_SECRET=executor-secret-key
88
OPR_EXECUTOR_LOGGING_PROVIDER=
99
OPR_EXECUTOR_LOGGING_CONFIG=
1010
OPR_EXECUTOR_DOCKER_HUB_USERNAME=
11-
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
11+
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
12+
OPR_EXECUTOR_RUNTIME_VERSIONS=v3

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ services:
5959
- OPR_EXECUTOR_LOGGING_CONFIG
6060
- OPR_EXECUTOR_DOCKER_HUB_USERNAME
6161
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD
62+
- OPR_EXECUTOR_RUNTIME_VERSIONS
6263

6364
networks:
6465
openruntimes-runtimes:
@@ -85,6 +86,7 @@ OPR_EXECUTOR_LOGGING_PROVIDER=
8586
OPR_EXECUTOR_LOGGING_CONFIG=
8687
OPR_EXECUTOR_DOCKER_HUB_USERNAME=
8788
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
89+
OPR_EXECUTOR_RUNTIME_VERSIONS=v3
8890
```
8991

9092
> `OPR_EXECUTOR_CONNECTION_STORAGE` takes a DSN string that represents a connection to your storage device. If you would like to use your local filesystem, you can use `file://localhost`. If using S3 or any other provider for storage, use a DSN of the following format `s3://access_key:access_secret@host:port/bucket_name?region=us-east-1`

app/http.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,24 +1166,28 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr
11661166
/**
11671167
* Warmup: make sure images are ready to run fast 🚀
11681168
*/
1169-
Console::info('Pulling runtime images...');
1170-
$runtimes = new Runtimes('v3'); // TODO: @Meldiron Make part of open runtimes
11711169
$allowList = empty(App::getEnv('OPR_EXECUTOR_RUNTIMES')) ? [] : \explode(',', App::getEnv('OPR_EXECUTOR_RUNTIMES'));
1172-
$runtimes = $runtimes->getAll(true, $allowList);
1173-
$callables = [];
1174-
foreach ($runtimes as $runtime) {
1175-
$callables[] = function () use ($runtime, $orchestration) {
1176-
Console::log('Warming up ' . $runtime['name'] . ' ' . $runtime['version'] . ' environment...');
1177-
$response = $orchestration->pull($runtime['image']);
1178-
if ($response) {
1179-
Console::info("Successfully Warmed up {$runtime['name']} {$runtime['version']}!");
1180-
} else {
1181-
Console::warning("Failed to Warmup {$runtime['name']} {$runtime['version']}!");
1182-
}
1183-
};
1184-
}
11851170

1186-
batch($callables);
1171+
$runtimeVersions = \explode(',', App::getEnv('OPR_EXECUTOR_RUNTIME_VERSIONS', 'v3') ?? 'v3');
1172+
foreach ($runtimeVersions as $runtimeVersion) {
1173+
Console::success("Pulling $runtimeVersion images...");
1174+
$runtimes = new Runtimes($runtimeVersion); // TODO: @Meldiron Make part of open runtimes
1175+
$runtimes = $runtimes->getAll(true, $allowList);
1176+
$callables = [];
1177+
foreach ($runtimes as $runtime) {
1178+
$callables[] = function () use ($runtime, $orchestration) {
1179+
Console::log('Warming up ' . $runtime['name'] . ' ' . $runtime['version'] . ' environment...');
1180+
$response = $orchestration->pull($runtime['image']);
1181+
if ($response) {
1182+
Console::info("Successfully Warmed up {$runtime['name']} {$runtime['version']}!");
1183+
} else {
1184+
Console::warning("Failed to Warmup {$runtime['name']} {$runtime['version']}!");
1185+
}
1186+
};
1187+
}
1188+
1189+
batch($callables);
1190+
}
11871191

11881192
Console::success("Image pulling finished.");
11891193

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ services:
4444
- OPR_EXECUTOR_LOGGING_CONFIG
4545
- OPR_EXECUTOR_DOCKER_HUB_USERNAME
4646
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD
47+
- OPR_EXECUTOR_RUNTIME_VERSIONS
4748

4849
networks:
4950
openruntimes-runtimes:

0 commit comments

Comments
 (0)