Skip to content

Commit

Permalink
add APP_PERSISTENT_STORAGE env (#74)
Browse files Browse the repository at this point in the history
Resolves: #33

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
  • Loading branch information
andrey18106 authored Sep 14, 2023
1 parent 2971c91 commit ef4f5ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/tech_details/Deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DockerActions implements IDeployActions {
'APP_PROTOCOL',
'APP_HOST',
'APP_PORT',
'APP_PERSISTENT_STORAGE',
'IS_SYSTEM_APP',
'NEXTCLOUD_URL',
];
Expand Down Expand Up @@ -334,13 +335,15 @@ 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'];
}, (array) $containerInfo['HostConfig']['Devices']);
} else {
$port = $this->service->getExAppRandomPort();
$devices = $deployConfig['gpus'];
$storage = $this->buildDefaultExAppVolume($appId);
}

$imageParams = [
Expand All @@ -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);
Expand Down Expand Up @@ -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(''))),
];
Expand Down

0 comments on commit ef4f5ec

Please sign in to comment.