Lue dans les fichiers PHP du paquet au commit f8a7c20c4dde : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.
DockerFactoryclass"docker": options services (by service name: image, port, env, command, address, network, labels, host_port, memory, cpus - see Template), host ("unix:///var/run/docker.sock", "tcp://10.0.0.5:2375", "https://10.0.0.5:2376"), api_version ("v1.44"), public_host (where players reach the published ports), region ("local"), secret_env ("OMNIPLAY_TICKET_SECRET"), name_prefix ("omniplay-"), auto_remove (true), stop_timeout (10 seconds), tls (the HTTP client's cafile, local_cert, local_pk for a TLS engine), heartbeat_url (the application's heartbeat route, handed to each server as OMNIPLAY_HEARTBEAT_URL), user_agent.
12 options · 1 method
DockerHostingclassGame servers as containers of a Docker Engine, through its HTTP API: a server is created from its service's template (POST /containers/create), started, and inspected for the host port Docker published; it is stopped (and removed, unless Docker removes it itself) by its container's id.
7 methods · 1 constant
TemplateclassWhat a server of one service runs, as the configuration gives it: the image, the port the server listens on inside its container ("7777/udp"), its command, its environment, the address players are given ("{host}" the provider's public host, "{port}" the port Docker published), and what Docker limits it to.
2 methods · 10 properties
Omniplay\Docker
DockerFactory class
final class DockerFactory extends ProviderFactory DockerFactory.php:24
"docker": options services (by service name: image, port, env, command, address, network, labels, host_port, memory, cpus - see Template), host ("unix:///var/run/docker.sock", "tcp://10.0.0.5:2375", "https://10.0.0.5:2376"), api_version ("v1.44"), public_host (where players reach the published ports), region ("local"), secret_env ("OMNIPLAY_TICKET_SECRET"), name_prefix ("omniplay-"), auto_remove (true), stop_timeout (10 seconds), tls (the HTTP client's cafile, local_cert, local_pk for a TLS engine), heartbeat_url (the application's heartbeat route, handed to each server as OMNIPLAY_HEARTBEAT_URL), user_agent.
Options
| Option | Default | |
|---|---|---|
services | [] | required |
host | 'unix:///var/run/docker.sock' | |
api_version | 'v1.44' | |
public_host | '127.0.0.1' | |
region | 'local' | |
secret_env | 'OMNIPLAY_TICKET_SECRET' | |
name_prefix | 'omniplay-' | |
auto_remove | true | |
stop_timeout | 10 | |
tls | [] | |
heartbeat_url | null | |
user_agent | 'omniplay/1.0 (+https://github.com/glitchr-omnisense/omniplay)' |
DockerFactory::__construct()
public function __construct(readonly ?HttpClientInterface $http = null)DockerHosting class
final class DockerHosting implements ProviderInterface, HostingInterface DockerHosting.php:34
Game servers as containers of a Docker Engine, through its HTTP API: a server is created from its service's template (POST /containers/create), started, and inspected for the host port Docker published; it is stopped (and removed, unless Docker removes it itself) by its container's id.
The server's environment holds its ticket secret (OMNIPLAY_TICKET_SECRET unless configured otherwise), its id - which is its tickets' room - (OMNIPLAY_SERVER_ID, OMNIPLAY_ROOM), its service, capacity, port, declared engine and the application's heartbeat route (OMNIPLAY_HEARTBEAT_URL, when configured). The secret goes into the container and nowhere else: not into the Server returned, not into its labels. Whoever can read the engine's API (docker inspect) reads it: the engine's socket is root's.
Its labels (omniplay.server, .service, .capacity, .region, .tags, .engine, .port) are what running() rebuilds the servers from.
const LABEL = 'omniplay.'
DockerHosting::__construct()
public function __construct(readonly JsonClient $json, readonly string $base, readonly array $templates, readonly string $publicHost = '127.0.0.1', readonly string $region = 'local', readonly string $secretEnv = 'OMNIPLAY_TICKET_SECRET', readonly string $prefix = 'omniplay-', readonly bool $autoRemove = true, readonly int $stopTimeout = 10, readonly array $options = [], readonly string $where = 'a Docker Engine', readonly ?string $heartbeatUrl = null)$templatesby service
$optionsthe HTTP client's, on every call (a unix socket's "bindto")
DockerHosting::getName()
public function getName(): stringDockerHosting::getTitle()
public function getTitle(): stringDockerHosting::capabilities()
public function capabilities(): CapabilitiesDockerHosting::start()
public function start(Service $service, string $secret, ?string $region = null, array $tags = []): ServerDockerHosting::stop()
public function stop(Server $server): voidDockerHosting::running()
public function running(?string $service = null): arrayTemplate class
final readonly class Template Template.php:14
What a server of one service runs, as the configuration gives it: the image, the port the server listens on inside its container ("7777/udp"), its command, its environment, the address players are given ("{host}" the provider's public host, "{port}" the port Docker published), and what Docker limits it to.
public string $imagepublic string $portpublic array $envthe server's own variables (omniplay's are set after them)
public ?array $commandthe image's command when null
public string $addresspublic ?string $networkpublic array $labelsbesides omniplay's
public ?int $hostPortthe host port to publish on (one server at a time); any free one when null
public ?int $memorybytes
public ?float $cpus
Template::__construct()
public function __construct(public string $image, public string $port = '7777/udp', public array $env = [], public ?array $command = null, public string $address = '{host}:{port}', public ?string $network = null, public array $labels = [], public ?int $hostPort = null, public ?int $memory = null, public ?float $cpus = null)$envthe server's own variables (omniplay's are set after them)
$commandthe image's command when null
$labelsbesides omniplay's
$hostPortthe host port to publish on (one server at a time); any free one when null
$memorybytes
Template::fromArray()
public static function fromArray(string $service, array $values): selfA service's entry of the "services" option.