Skip to content

Commit

Permalink
Setup separate daemon config if GPU enabled in AIO (#134)
Browse files Browse the repository at this point in the history
Setup separate daemon config with GPU flag enabled if AIO configured
with GPU to avoid broken setup in case of missing host machine
configuration to use GPU in AIO. For now supported only NVIDIA, that
requires a few packages to be installed to support GPU passthrough into
Docker containers.

Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 authored Dec 13, 2023
1 parent ded2eb4 commit 7306d74
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion lib/DeployActions/AIODockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class AIODockerActions {
public const AIO_DAEMON_CONFIG_NAME = 'docker_aio';
public const AIO_DAEMON_CONFIG_NAME_GPU = 'docker_aio_gpu';
public const AIO_DOCKER_SOCKET_PROXY_HOST = 'nextcloud-aio-docker-socket-proxy:2375';

public function __construct(
Expand Down Expand Up @@ -57,7 +58,7 @@ public function registerAIODaemonConfig(): ?DaemonConfig {
];

if ($this->isGPUsEnabled()) {
$deployConfig['gpu'] = true;
$this->registerAIODaemonConfigWithGPU();
}

$daemonConfigParams = [
Expand All @@ -76,6 +77,40 @@ public function registerAIODaemonConfig(): ?DaemonConfig {
return $daemonConfig;
}

/**
* Registers DaemonConfig with default params to use AIO Docker Socket Proxy with GPU
*
* @return DaemonConfig|null
*/
private function registerAIODaemonConfigWithGPU(): ?DaemonConfig {
$daemonConfigWithGPU = $this->daemonConfigService->getDaemonConfigByName(self::AIO_DAEMON_CONFIG_NAME_GPU);
if ($daemonConfigWithGPU !== null) {
return $daemonConfigWithGPU;
}

$deployConfig = [
'net' => 'nextcloud-aio', // using the same host as default network for Nextcloud AIO containers
'host' => null,
'nextcloud_url' => 'https://' . getenv('NC_DOMAIN'),
'ssl_key' => null,
'ssl_key_password' => null,
'ssl_cert' => null,
'ssl_cert_password' => null,
'gpu' => true,
];

$daemonConfigParams = [
'name' => self::AIO_DAEMON_CONFIG_NAME,
'display_name' => 'AIO Docker Socket Proxy with GPU',
'accepts_deploy_id' => 'docker-install',
'protocol' => 'http',
'host' => self::AIO_DOCKER_SOCKET_PROXY_HOST,
'deploy_config' => $deployConfig,
];

return $this->daemonConfigService->registerDaemonConfig($daemonConfigParams);
}

/**
* Check if /dev/dri folder mounted to the container.
* In AIO this means that NEXTCLOUD_ENABLE_DRI_DEVICE=true
Expand Down

0 comments on commit 7306d74

Please sign in to comment.