-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathRuntimes.php
177 lines (148 loc) · 13 KB
/
Runtimes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
namespace Appwrite\Runtimes;
use Exception;
use Utopia\System\System;
class Runtimes
{
/** @var array<string, Runtime> */
protected $runtimes = [];
protected string $version;
/**
* Runtimes.
*/
public function __construct(string $version = '')
{
$this->version = $version;
$node = new Runtime('node', 'Node.js', 'sh helpers/server.sh');
$node->addVersion('14.5', 'node:14.5.0-alpine3.12', 'openruntimes/node:'.$this->version.'-14.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$node->addVersion('16.0', 'node:16.20.2-alpine3.18', 'openruntimes/node:'.$this->version.'-16.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$node->addVersion('18.0', 'node:18.20.4-alpine3.20', 'openruntimes/node:'.$this->version.'-18.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$node->addVersion('19.0', 'node:19.9.0-alpine3.18', 'openruntimes/node:'.$this->version.'-19.0', [System::X86, System::ARM64]);
$node->addVersion('20.0', 'node:20.17.0-alpine3.20', 'openruntimes/node:'.$this->version.'-20.0', [System::X86, System::ARM64]);
$node->addVersion('21.0', 'node:21.7.3-alpine3.20', 'openruntimes/node:'.$this->version.'-21.0', [System::X86, System::ARM64]);
$node->addVersion('22', 'node:22.9.0-alpine3.20', 'openruntimes/node:'.$this->version.'-22', [System::X86, System::ARM64]);
$this->runtimes['node'] = $node;
$php = new Runtime('php', 'PHP', 'sh helpers/server.sh');
$php->addVersion('8.0', 'php:8.0.30-cli-alpine3.16', 'openruntimes/php:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$php->addVersion('8.1', 'php:8.1.30-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$php->addVersion('8.2', 'php:8.2.24-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.2', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$php->addVersion('8.3', 'php:8.3.12-cli-alpine3.20', 'openruntimes/php:'.$this->version.'-8.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['php'] = $php;
$ruby = new Runtime('ruby', 'Ruby', 'sh helpers/server.sh');
$ruby->addVersion('3.0', 'ruby:3.0.7-alpine3.16', 'openruntimes/ruby:'.$this->version.'-3.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$ruby->addVersion('3.1', 'ruby:3.1.6-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$ruby->addVersion('3.2', 'ruby:3.2.5-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.2', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$ruby->addVersion('3.3', 'ruby:3.3.5-alpine3.20', 'openruntimes/ruby:'.$this->version.'-3.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['ruby'] = $ruby;
$python = new Runtime('python', 'Python', 'sh helpers/server.sh');
$python->addVersion('3.8', 'python:3.8.20-alpine3.20', 'openruntimes/python:'.$this->version.'-3.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$python->addVersion('3.9', 'python:3.9.20-alpine3.20', 'openruntimes/python:'.$this->version.'-3.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$python->addVersion('3.10', 'python:3.10.15-alpine3.20', 'openruntimes/python:'.$this->version.'-3.10', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$python->addVersion('3.11', 'python:3.11.10-alpine3.20', 'openruntimes/python:'.$this->version.'-3.11', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$python->addVersion('3.12', 'python:3.12.6-alpine3.20', 'openruntimes/python:'.$this->version.'-3.12', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['python'] = $python;
$pythonML = new Runtime('python-ml', 'Python (ML)', 'sh helpers/server.sh');
$pythonML->addVersion('3.11', 'python:3.11.10-bookworm', 'openruntimes/python-ml:'.$this->version.'-3.11', [System::X86, System::ARM64]);
$this->runtimes['python-ml'] = $pythonML;
$deno = new Runtime('deno', 'Deno', 'sh helpers/server.sh');
$deno->addVersion('1.21', 'denoland/deno:alpine-1.21.3', 'openruntimes/deno:'.$this->version.'-1.21', [System::X86]);
$deno->addVersion('1.24', 'denoland/deno:alpine-1.24.3', 'openruntimes/deno:'.$this->version.'-1.24', [System::X86]);
$deno->addVersion('1.35', 'denoland/deno:alpine-1.35.3', 'openruntimes/deno:'.$this->version.'-1.35', [System::X86]);
$deno->addVersion('1.40', 'denoland/deno:alpine-1.40.5', 'openruntimes/deno:'.$this->version.'-1.40', [System::X86, System::ARM64]);
$deno->addVersion('1.46', 'denoland/deno:alpine-1.46.3', 'openruntimes/deno:'.$this->version.'-1.46', [System::X86, System::ARM64]);
$deno->addVersion('2.0', 'denoland/deno:alpine-2.0.0-rc.5', 'openruntimes/deno:'.$this->version.'-2.0', [System::X86, System::ARM64]);
$this->runtimes['deno'] = $deno;
$dart = new Runtime('dart', 'Dart', 'sh helpers/server.sh');
$dart->addVersion('2.15', 'dart:2.15.1', 'openruntimes/dart:'.$this->version.'-2.15', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('2.16', 'dart:2.16.2', 'openruntimes/dart:'.$this->version.'-2.16', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('2.17', 'dart:2.17.7', 'openruntimes/dart:'.$this->version.'-2.17', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('2.18', 'dart:2.18.7', 'openruntimes/dart:'.$this->version.'-2.18', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('2.18', 'dart:2.19.6', 'openruntimes/dart:'.$this->version.'-2.19', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('3.0', 'dart:3.0.7', 'openruntimes/dart:'.$this->version.'-3.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('3.1', 'dart:3.1.5', 'openruntimes/dart:'.$this->version.'-3.1', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('3.3', 'dart:3.3.4', 'openruntimes/dart:'.$this->version.'-3.3', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dart->addVersion('3.5', 'dart:3.5.2', 'openruntimes/dart:'.$this->version.'-3.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['dart'] = $dart;
$dotnet = new Runtime('dotnet', '.NET', 'sh helpers/server.sh');
$dotnet->addVersion('6.0', 'mcr.microsoft.com/dotnet/sdk:6.0.425-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-6.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dotnet->addVersion('7.0', 'mcr.microsoft.com/dotnet/sdk:7.0.410-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-7.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$dotnet->addVersion('8.0', 'mcr.microsoft.com/dotnet/sdk:8.0.402-alpine3.19', 'openruntimes/dotnet:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['dotnet'] = $dotnet;
$java = new Runtime('java', 'Java', 'sh helpers/server.sh');
$java->addVersion('8.0', 'eclipse-temurin:8-jdk-jammy', 'openruntimes/java:'.$this->version.'-8.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$java->addVersion('11.0', 'eclipse-temurin:11-jdk-jammy', 'openruntimes/java:'.$this->version.'-11.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$java->addVersion('17.0', 'eclipse-temurin:17-jdk-jammy', 'openruntimes/java:'.$this->version.'-17.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$java->addVersion('18.0', 'eclipse-temurin:18-jdk-jammy', 'openruntimes/java:'.$this->version.'-18.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$java->addVersion('21.0', 'eclipse-temurin:21-jdk-jammy', 'openruntimes/java:'.$this->version.'-21.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$java->addVersion('22', 'eclipse-temurin:22-jdk-jammy', 'openruntimes/java:'.$this->version.'-22', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['java'] = $java;
$swift = new Runtime('swift', 'Swift', 'sh helpers/server.sh');
$swift->addVersion('5.5', 'swiftarm/swift:5.5.3-ubuntu-jammy', 'openruntimes/swift:'.$this->version.'-5.5', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$swift->addVersion('5.8', 'swiftarm/swift:5.8.1-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$swift->addVersion('5.9', 'swiftarm/swift:5.9.2-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$swift->addVersion('5.10', 'swiftarm/swift:5.10-ubuntu-22.04', 'openruntimes/swift:'.$this->version.'-5.10', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['swift'] = $swift;
$kotlin = new Runtime('kotlin', 'Kotlin', 'sh helpers/server.sh');
$kotlin->addVersion('1.6', 'eclipse-temurin:18-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.6', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$kotlin->addVersion('1.8', 'eclipse-temurin:19-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.8', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$kotlin->addVersion('1.9', 'eclipse-temurin:19-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-1.9', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$kotlin->addVersion('2.0', 'eclipse-temurin:22-jdk-alpine', 'openruntimes/kotlin:'.$this->version.'-2.0', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['kotlin'] = $kotlin;
$cpp = new Runtime('cpp', 'C++', 'sh helpers/server.sh');
$cpp->addVersion('17', 'alpine:3.20.2', 'openruntimes/cpp:'.$this->version.'-17', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$cpp->addVersion('20', 'alpine:3.20.2', 'openruntimes/cpp:'.$this->version.'-20', [System::X86, System::ARM64, System::ARMV7, System::ARMV8]);
$this->runtimes['cpp'] = $cpp;
$bun = new Runtime('bun', 'Bun', 'sh helpers/server.sh');
$bun->addVersion('1.0', 'oven/bun:1.0.36-alpine', 'openruntimes/bun:'.$this->version.'-1.0', [System::X86, System::ARM64]);
$bun->addVersion('1.1', 'oven/bun:1.1.29-alpine', 'openruntimes/bun:'.$this->version.'-1.1', [System::X86, System::ARM64]);
$this->runtimes['bun'] = $bun;
$go = new Runtime('go', 'Go', 'sh helpers/server.sh');
$go->addVersion('1.23', 'golang:1.23.1-alpine3.20', 'openruntimes/go:'.$this->version.'-1.23', [System::X86, System::ARM64]);
$this->runtimes['go'] = $go;
$static = new Runtime('static', 'Static', 'sh helpers/server.sh');
$static->addVersion('1', 'joseluisq/static-web-server:2.33-alpine', 'openruntimes/static:'.$this->version.'-1', [System::X86, System::ARM64]);
$this->runtimes['static'] = $static;
$flutter = new Runtime('flutter', 'Flutter', 'sh helpers/server.sh');
$flutter->addVersion('3.24', 'dart:3.5.2', 'openruntimes/flutter:'.$this->version.'-3.24', [System::X86, System::ARM64]);
$this->runtimes['flutter'] = $flutter;
$ssr = new Runtime('ssr', 'SSR', 'sh helpers/server.sh');
$ssr->addVersion('22', 'node:22.9.0-alpine3.20', 'openruntimes/ssr:' . $this->version . '-22', [System::X86, System::ARM64]);
$this->runtimes['ssr'] = $ssr;
}
/**
* Adds runtime.
*/
public function add(Runtime $runtime): void
{
$this->runtimes[$runtime->getKey()] = $runtime;
}
/**
* Get Runtime by key.
*/
public function get(string $key): Runtime
{
if (! array_key_exists($key, $this->runtimes)) {
throw new Exception('Runtime not found!');
}
return $this->runtimes[$key];
}
/**
* Returns all supported runtimes.
*
* @param bool $supported Pass `false` to also return unsupported CPU architecture.
* @param array<mixed> $filter
* @return array<mixed>
*/
public function getAll(bool $supported = true, array $filter = []): array
{
$supportedRuntimes = [];
foreach ($this->runtimes as $runtime) {
$supportedRuntimes = array_merge(array_reverse(array_filter($runtime->list(), function (array $version, string $key) use ($supported, $filter) {
$isSupported = in_array(System::getArchEnum(), $version['supports']);
$isFiltered = in_array($key, $filter);
return $supported ? ($isSupported && ($filter ? $isFiltered : true)) : true;
}, ARRAY_FILTER_USE_BOTH)), $supportedRuntimes);
}
return array_reverse($supportedRuntimes);
}
}