Skip to content

Commit

Permalink
Merge branch 'main' into new-fileaction-support
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 authored Oct 23, 2023
2 parents c660248 + f0f787c commit 6fa6f04
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
24 changes: 1 addition & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ help:
@echo " dock-port create docker daemons for Nextcloud 28, 27 (host.docker.internal:8443)"
@echo " dock-port28 create docker daemon for Nextcloud 28 (host.docker.internal:8443)"
@echo " dock-port27 create docker daemon for Nextcloud 27 (host.docker.internal:8443)"
@echo " "
@echo " "
@echo " example-deploy deploy Example App to docker"
@echo " example28 register & enable Example App in Nextcloud 28"
@echo " example27 register & enable Example App in Nextcloud 27"

.PHONY: dock-sock
dock-sock:
Expand All @@ -45,7 +40,7 @@ dock-sock28:
.PHONY: dock-sock27
dock-sock27:
@echo "creating daemon for nextcloud 'stable27' container"
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true
docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:unregister docker_dev || true
docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:register \
docker_dev Docker docker-install unix-socket /var/run/docker.sock http://stable27/index.php --net=master_default

Expand Down Expand Up @@ -86,20 +81,3 @@ dock-port27:
docker exec master-stable27-1 sudo -u www-data php occ app_api:daemon:register \
docker_dev Docker docker-install https host.docker.internal:6443 http://stable27/index.php \
--net=master_default --ssl_cert /client/cert.pem --ssl_key /client/key.pem

.PHONY: example-deploy
example-deploy:
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy skeleton docker_dev \
--info-xml https://raw.githubusercontent.com/cloud-py-api/nc_py_api/main/examples/as_app/skeleton/appinfo/info.xml

.PHONY: example28
example28:
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister skeleton --silent || true
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register skeleton docker_dev
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:enable skeleton

.PHONY: example27
example27:
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister skeleton --silent || true
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register skeleton docker_dev
docker exec master-stable27-1 sudo -u www-data php occ app_api:app:enable skeleton
3 changes: 1 addition & 2 deletions docs/ManagingExternalApplications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Options
Register
--------

Command: ``app_api:app:register [-e|--enabled] [--force-scopes] [--info-xml INFO-XML] [--json-info JSON-INFO] [--] <appid> <daemon-config-name>``
Command: ``app_api:app:register [--force-scopes] [--info-xml INFO-XML] [--json-info JSON-INFO] [--] <appid> <daemon-config-name>``

The register command is the second ExApp installation step.

Expand All @@ -57,7 +57,6 @@ Arguments
Options
*******

* ``-e|--enabled`` *[optional]* - enable ExApp after registration
* ``--force-scopes`` *[optional]* - force scopes approval
* ``--json-info JSON-INFO`` **[optional]** - ExApp deploy JSON info (json string)
* ``--info-xml INFO-XML`` **[required]** - path to info.xml file (url or local absolute path)
Expand Down
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
# switch.
nitpicky = True

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["resources"]


def setup(app):
app.add_js_file("js/script.js")
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ th p {
font-size: 1rem;
margin-bottom: 0;
}

.wy-nav-content {
max-width: 80% !important;
}
15 changes: 11 additions & 4 deletions docs/tech_details/Deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ This can be done by ``occ`` CLI command **app_api:app:deploy**:
For development this step is skipped, as ExApp is deployed and started manually by developer.

.. warning::
After successful deployment (pull, create and start container), there is a heartbeat check with 1 hour timeout (will be configurable).
If command seems to be stuck, check if ExApp is running and accessible by Nextcloud instance.
After successful deployment (pull, create and start container), there is a heartbeat check with 90 seconds timeout (will be configurable).

Arguments
*********
Expand Down Expand Up @@ -193,7 +192,7 @@ This can be done by ``occ`` CLI command **app_api:app:register**:

.. code-block:: bash
app_api:app:register <appid> <daemon-config-name> [-e|--enabled] [--force-scopes] [--]
app_api:app:register <appid> <daemon-config-name> [--force-scopes] [--]
Arguments
*********
Expand All @@ -204,13 +203,21 @@ Arguments
Options
*******

* ``-e|--enabled`` *[optional]* - enable ExApp after registration
* ``--force-scopes`` *[optional]* - force scopes approval
* ``--json-info JSON-INFO`` **[required]** - path to JSON file with deploy result (url or local absolute path)

With provided ``appid`` and ``daemon-config-name``, Nextcloud will retrieve ExApp info from deployed container and register it.
In case of ``manual-install`` DeployConfig type, ExApp info must be provided by ``--json-info`` option `as described before <#deploy-result-json-output>`_.

Application installation scheme
-------------------------------

1. AppAPI deploys the application and launches it.
2. AppAPI for `N` seconds (default ``90``) checks the ``/heartbeat`` endpoint with ``GET`` request.
3. AppAPI sends a ``POST`` to the ``/init`` endpoint.
4. ExApp sends an integer from ``0`` to ``100` to the OCS endpoint ``apps/app_api/apps/status`` indicating the initialization progress. After sending ``100``, the application is considered initialized.
5. AppAPI sends a PUT to the ``/enabled`` endpoint.

ExApp info.xml schema
---------------------

Expand Down
2 changes: 1 addition & 1 deletion lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public function containerStateHealthy(array $containerInfo): bool {

public function healthcheckContainer(string $containerId, DaemonConfig $daemonConfig): bool {
$attempts = 0;
$totalAttempts = 60; // ~60 seconds for container to initialize
$totalAttempts = 90; // ~90 seconds for container to initialize
while ($attempts < $totalAttempts) {
$containerInfo = $this->inspectContainer($this->buildDockerUrl($daemonConfig), $containerId);
if ($this->containerStateHealthy($containerInfo)) {
Expand Down

0 comments on commit 6fa6f04

Please sign in to comment.