From ef4f5ec5e287edc78af2bc59361b8805e4e6be0f Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Thu, 14 Sep 2023 17:49:36 +0300 Subject: [PATCH] add APP_PERSISTENT_STORAGE env (#74) Resolves: #33 --------- Signed-off-by: Andrey Borysenko --- docs/tech_details/Deployment.rst | 1 + lib/DeployActions/DockerActions.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/tech_details/Deployment.rst b/docs/tech_details/Deployment.rst index 5435b2ff..8bf4d6d6 100644 --- a/docs/tech_details/Deployment.rst +++ b/docs/tech_details/Deployment.rst @@ -165,6 +165,7 @@ The following env variables are required and built automatically: * ``APP_PROTOCOL`` - protocol ExApp is listening on (http|https) * ``APP_HOST`` - host ExApp is listening on * ``APP_PORT`` - port ExApp is listening on (randomly selected by AppAPI) + * ``APP_PERSISTENT_STORAGE`` - path to mounted volume for persistent data storage between ExApp updates * ``IS_SYSTEM_APP`` - ExApp system app flag (true|false) * ``NEXTCLOUD_URL`` - Nextcloud URL to connect to diff --git a/lib/DeployActions/DockerActions.php b/lib/DeployActions/DockerActions.php index a35225b8..c3759e9a 100644 --- a/lib/DeployActions/DockerActions.php +++ b/lib/DeployActions/DockerActions.php @@ -29,6 +29,7 @@ class DockerActions implements IDeployActions { 'APP_PROTOCOL', 'APP_HOST', 'APP_PORT', + 'APP_PERSISTENT_STORAGE', 'IS_SYSTEM_APP', 'NEXTCLOUD_URL', ]; @@ -334,6 +335,7 @@ public function buildDeployParams(DaemonConfig $daemonConfig, \SimpleXMLElement $oldEnvs = $this->extractDeployEnvs((array) $containerInfo['Config']['Env']); $port = $oldEnvs['APP_PORT'] ?? $this->service->getExAppRandomPort(); $secret = $oldEnvs['APP_SECRET']; + $storage = $oldEnvs['APP_PERSISTENT_STORAGE']; // Preserve previous devices or use from params (if any) $devices = array_map(function (array $device) { return $device['PathOnHost']; @@ -341,6 +343,7 @@ public function buildDeployParams(DaemonConfig $daemonConfig, \SimpleXMLElement } else { $port = $this->service->getExAppRandomPort(); $devices = $deployConfig['gpus']; + $storage = $this->buildDefaultExAppVolume($appId); } $imageParams = [ @@ -356,6 +359,7 @@ public function buildDeployParams(DaemonConfig $daemonConfig, \SimpleXMLElement 'protocol' => (string) ($infoXml->xpath('ex-app/protocol')[0] ?? 'http'), 'host' => $this->service->buildExAppHost($deployConfig), 'port' => $port, + 'storage' => $storage, 'system_app' => (bool) ($infoXml->xpath('ex-app/system')[0] ?? false), 'secret' => $secret ?? $this->random->generate(128), ], $params['env_options'] ?? [], $deployConfig); @@ -396,6 +400,7 @@ public function buildDeployEnvs(array $params, array $envOptions, array $deployC sprintf('APP_PROTOCOL=%s', $params['protocol']), sprintf('APP_HOST=%s', $params['host']), sprintf('APP_PORT=%s', $params['port']), + sprintf('APP_PERSISTENT_STORAGE=%s', $params['storage']), sprintf('IS_SYSTEM_APP=%s', $params['system_app']), sprintf('NEXTCLOUD_URL=%s', $deployConfig['nextcloud_url'] ?? str_replace('https', 'http', $this->urlGenerator->getAbsoluteURL(''))), ];