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

Feat: Start commands #58

Merged
merged 13 commits into from
Aug 7, 2023
10 changes: 8 additions & 2 deletions src/Runtimes/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class Runtime
*/
protected $name;

/**
* @var string
*/
protected $startCommand;

/**
* @var Version[]
*/
Expand All @@ -25,11 +30,11 @@ class Runtime
* @param string $key
* @param string $name
*/
public function __construct(string $key, string $name)
public function __construct(string $key, string $name, string $startCommand)
{
$this->key = $key;
$this->name = $name;
$this->versions;
$this->startCommand = $startCommand;
}

/**
Expand Down Expand Up @@ -69,6 +74,7 @@ public function list(): array
[
'name' => $this->name,
'logo' => "{$this->key}.png",
'startCommand' => $this->startCommand
],
$version->get()
);
Expand Down
63 changes: 38 additions & 25 deletions src/Runtimes/Runtimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,74 @@ public function __construct($version = '')
{
$this->version = $version;

$node = new Runtime('node', 'Node.js');
$node->addVersion('14.5', 'node:14.5-alpine', 'openruntimes/node:' . $this->version . '-14.5', [System::X86, System::ARM]);
$node->addVersion('16.0', 'node:16-alpine', 'openruntimes/node:' . $this->version . '-16.0', [System::X86, System::ARM]);
$node->addVersion('18.0', 'node:18-alpine', 'openruntimes/node:' . $this->version . '-18.0', [System::X86, System::ARM]);
$node = new Runtime('node', 'Node.js', 'pm2 start src/server.js --no-daemon');
$node->addVersion('14.5', 'node:14.5-alpine3.12', 'openruntimes/node:' . $this->version . '-14.5', [System::X86, System::ARM]);
Meldiron marked this conversation as resolved.
Show resolved Hide resolved
$node->addVersion('16.0', 'node:16.0-alpine3.13', 'openruntimes/node:' . $this->version . '-16.0', [System::X86, System::ARM]);
$node->addVersion('18.0', 'node:18.0-alpine3.15', 'openruntimes/node:' . $this->version . '-18.0', [System::X86, System::ARM]);
$node->addVersion('19.0', 'node:19.0-alpine3.16', 'openruntimes/node:' . $this->version . '-19.0', [System::X86, System::ARM]);
$node->addVersion('20.0', 'node:20.0-alpine3.16', 'openruntimes/node:' . $this->version . '-20.0', [System::X86, System::ARM]);
$this->runtimes['node'] = $node;

$php = new Runtime('php', 'PHP');
$php->addVersion('8.0', 'php:8.0-cli-alpine', 'openruntimes/php:' . $this->version . '-8.0', [System::X86, System::ARM]);
$php->addVersion('8.1', 'php:8.1-cli-alpine', 'openruntimes/php:' . $this->version . '-8.1', [System::X86, System::ARM]);
$php = new Runtime('php', 'PHP', 'php src/server.php');
$php->addVersion('8.0', 'php:8.0-cli-alpine3.16', 'openruntimes/php:' . $this->version . '-8.0', [System::X86, System::ARM]);
$php->addVersion('8.1', 'php:8.1-cli-alpine3.16', 'openruntimes/php:' . $this->version . '-8.1', [System::X86, System::ARM]);
$php->addVersion('8.2', 'php:8.2-cli-alpine3.16', 'openruntimes/php:' . $this->version . '-8.2', [System::X86, System::ARM]);
$this->runtimes['php'] = $php;

$ruby = new Runtime('ruby', 'Ruby');
$ruby->addVersion('3.0', 'ruby:3.0-alpine', 'openruntimes/ruby:' . $this->version . '-3.0', [System::X86, System::ARM]);
$ruby->addVersion('3.1', 'ruby:3.1-alpine', 'openruntimes/ruby:' . $this->version . '-3.1', [System::X86, System::ARM]);
$ruby = new Runtime('ruby', 'Ruby', 'bundle exec puma -b tcp://0.0.0.0:3000 -e production');
$ruby->addVersion('3.0', 'ruby:3.0-alpine3.16', 'openruntimes/ruby:' . $this->version . '-3.0', [System::X86, System::ARM]);
$ruby->addVersion('3.1', 'ruby:3.1-alpine3.16', 'openruntimes/ruby:' . $this->version . '-3.1', [System::X86, System::ARM]);
$ruby->addVersion('3.2', 'ruby:3.2-alpine3.16', 'openruntimes/ruby:' . $this->version . '-3.2', [System::X86, System::ARM]);
$this->runtimes['ruby'] = $ruby;

$python = new Runtime('python', 'Python');
$python->addVersion('3.8', 'python:3.8-alpine', 'openruntimes/python:' . $this->version . '-3.8', [System::X86, System::ARM]);
$python->addVersion('3.9', 'python:3.9-alpine', 'openruntimes/python:' . $this->version . '-3.9', [System::X86, System::ARM]);
$python->addVersion('3.10', 'python:3.10-alpine', 'openruntimes/python:' . $this->version . '-3.10', [System::X86, System::ARM]);
$python = new Runtime('python', 'Python', 'python3 src/server.py');
$python->addVersion('3.8', 'python:3.8-alpine3.16', 'openruntimes/python:' . $this->version . '-3.8', [System::X86, System::ARM]);
$python->addVersion('3.9', 'python:3.9-alpine3.16', 'openruntimes/python:' . $this->version . '-3.9', [System::X86, System::ARM]);
$python->addVersion('3.10', 'python:3.10-alpine3.16', 'openruntimes/python:' . $this->version . '-3.10', [System::X86, System::ARM]);
$python->addVersion('3.11', 'python:3.11-alpine3.16', 'openruntimes/python:' . $this->version . '-3.11', [System::X86, System::ARM]);
$this->runtimes['python'] = $python;

$deno = new Runtime('deno', 'Deno');
$deno = new Runtime('deno', 'Deno', 'denon start');
Meldiron marked this conversation as resolved.
Show resolved Hide resolved
$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.2', 'openruntimes/deno:' . $this->version . '-1.35', [System::X86]);
$this->runtimes['deno'] = $deno;

$dart = new Runtime('dart', 'Dart');
$dart = new Runtime('dart', 'Dart', 'src/function/server');
$dart->addVersion('2.15', 'dart:2.15', 'openruntimes/dart:' . $this->version . '-2.15', [System::X86, System::ARM]);
$dart->addVersion('2.16', 'dart:2.16', 'openruntimes/dart:' . $this->version . '-2.16', [System::X86, System::ARM]);
$dart->addVersion('2.17', 'dart:2.17', 'openruntimes/dart:' . $this->version . '-2.17', [System::X86, System::ARM]);
$dart->addVersion('2.18', 'dart:2.18', 'openruntimes/dart:' . $this->version . '-2.18', [System::X86, System::ARM]);
$dart->addVersion('2.18', 'dart:2.19', 'openruntimes/dart:' . $this->version . '-2.19', [System::X86, System::ARM]);
$dart->addVersion('3.0', 'dart:3.0', 'openruntimes/dart:' . $this->version . '-3.0', [System::X86, System::ARM]);
$this->runtimes['dart'] = $dart;

$dotnet = new Runtime('dotnet', '.NET');
$dotnet = new Runtime('dotnet', '.NET', 'dotnet /src/function/DotNetRuntime.dll');
Meldiron marked this conversation as resolved.
Show resolved Hide resolved
$dotnet->addVersion('3.1', 'mcr.microsoft.com/dotnet/sdk:3.1', 'openruntimes/dotnet:' . $this->version . '-3.1', [System::X86, System::ARM]);
$dotnet->addVersion('6.0', 'mcr.microsoft.com/dotnet/sdk:6.0-alpine', 'openruntimes/dotnet:' . $this->version . '-6.0', [System::X86, System::ARM]);
$dotnet->addVersion('6.0', 'mcr.microsoft.com/dotnet/sdk:6.0-alpine3.18', 'openruntimes/dotnet:' . $this->version . '-6.0', [System::X86, System::ARM]);
$dotnet->addVersion('7.0', 'mcr.microsoft.com/dotnet/sdk:7.0-alpine3.18', 'openruntimes/dotnet:' . $this->version . '-7.0', [System::X86, System::ARM]);
$this->runtimes['dotnet'] = $dotnet;

$java = new Runtime('java', 'Java');
$java = new Runtime('java', 'Java', 'java -jar src/function/java-runtime-1.0.0.jar');
$java->addVersion('8.0', 'openjdk/8-jdk-slim', 'openruntimes/java:' . $this->version . '-8.0', [System::X86, System::ARM]);
$java->addVersion('11.0', 'openjdk/11-jdk-slim', 'openruntimes/java:' . $this->version . '-11.0', [System::X86, System::ARM]);
$java->addVersion('17.0', 'openjdk/17-jdk-slim', 'openruntimes/java:' . $this->version . '-17.0', [System::X86, System::ARM]);
$java->addVersion('18.0', 'openjdk/18-jdk-slim', 'openruntimes/java:' . $this->version . '-18.0', [System::X86, System::ARM]);
$this->runtimes['java'] = $java;

$swift = new Runtime('swift', 'Swift');
$swift->addVersion('5.5', 'swiftarm/swift:5.5.2-focal-multi-arch', 'openruntimes/swift:' . $this->version . '-5.5', [System::X86, System::ARM]);
$swift = new Runtime('swift', 'Swift', 'src/function/Runtime serve --env production --hostname 0.0.0.0 --port 3000');
$swift->addVersion('5.5', 'swiftarm/swift:5.5.3-ubuntu-jammy', 'openruntimes/swift:' . $this->version . '-5.5', [System::X86, System::ARM]);
$swift->addVersion('5.8', 'swiftarm/swift:5.8-ubuntu-jammy', 'openruntimes/swift:' . $this->version . '-5.8', [System::X86, System::ARM]);
$this->runtimes['swift'] = $swift;

$kotlin = new Runtime('kotlin', 'Kotlin');
$kotlin->addVersion('1.6', 'openjdk/17-jdk-slim', 'openruntimes/kotlin:' . $this->version . '-1.6', [System::X86, System::ARM]);
$kotlin = new Runtime('kotlin', 'Kotlin', 'java -jar src/function/kotlin-runtime-1.0.0.jar');
$kotlin->addVersion('1.6', 'openjdk/18-jdk-slim', 'openruntimes/kotlin:' . $this->version . '-1.6', [System::X86, System::ARM]);
$kotlin->addVersion('1.8', 'openjdk/19-jdk-slim', 'openruntimes/kotlin:' . $this->version . '-1.8', [System::X86, System::ARM]);
$this->runtimes['kotlin'] = $kotlin;

$cpp = new Runtime('cpp', 'C++');
$cpp->addVersion('17.0', 'alpine:3.15', 'openruntimes/cpp:' . $this->version . '-17', [System::X86, System::ARM]);
$cpp = new Runtime('cpp', 'C++', 'src/function/cpp_runtime');
$cpp->addVersion('17', 'alpine:3.16', 'openruntimes/cpp:' . $this->version . '-17', [System::X86, System::ARM]);
$cpp->addVersion('20', 'alpine:3.16', 'openruntimes/cpp:' . $this->version . '-20', [System::X86, System::ARM]);
$this->runtimes['cpp'] = $cpp;
}

Expand Down