Skip to content

Commit 8567c50

Browse files
committed
feat(Admin/AppAPI): add docker registries docs
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 093ea96 commit 8567c50

3 files changed

Lines changed: 184 additions & 1 deletion

File tree

admin_manual/exapps_management/ManagingDeployDaemons.rst

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ There are a few OCC CLI commands to manage Deploy Daemons:
1111
1. Register ``occ app_api:daemon:register``
1212
2. Unregister ``occ app_api:daemon:unregister``
1313
3. List registered daemons ``occ app_api:daemon:list``
14+
4. Add a Docker registry mapping ``occ app_api:daemon:registry:add``
15+
5. Remove a Docker registry mapping ``occ app_api:daemon:registry:remove``
16+
6. List Docker registry mappings ``occ app_api:daemon:registry:list``
1417

1518
Register
1619
--------
@@ -92,6 +95,8 @@ Usage Examples
9295
app_api:daemon:register local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda
9396
9497
98+
.. _deploy_config:
99+
95100
DeployConfig
96101
************
97102

@@ -112,7 +117,14 @@ ExApp container.
112117
"frp_address": "localhost:8782",
113118
"docker_socket_port": "24000",
114119
"exapp_direct": false
115-
}
120+
},
121+
"resourceLimits": {
122+
"memory": 2147483648,
123+
"nanoCPUs": 2000000000
124+
},
125+
"registries": [
126+
{"from": "ghcr.io", "to": "registry.example.com"}
127+
]
116128
}
117129
118130
DeployConfig options
@@ -126,6 +138,10 @@ DeployConfig options
126138
* ``frp_address`` *[optional]* - [host]:[port] of the HaRP FRP server, default host is same as HaRP host and port is 8782
127139
* ``docker_socket_port`` *[optional]* - 'remotePort' of the FRP client of the remote docker socket proxy. There is one included in the harp container so this can be skipped for default setups. [default: "24000"]
128140
* ``exapp_direct`` *[optional]* - Flag for the advanced setups only. Disables the FRP tunnel between ExApps and HaRP.
141+
* ``resourceLimits`` *[optional]* - limits applied to each ExApp container deployed by this daemon. Empty (``[]``) when no limits are set, and absent for daemons registered over the CLI, both of which mean unlimited. Each limit is only present when it is set
142+
* ``memory`` *[optional]* - memory limit **in bytes** (e.g. ``2147483648`` for 2 GiB). In the admin settings this is entered in MiB
143+
* ``nanoCPUs`` *[optional]* - CPU limit **in nanoCPUs**, where ``1000000000`` equals one CPU core (e.g. ``2000000000`` for 2 cores). In the admin settings this is entered in cores
144+
* ``registries`` *[optional]* - list of :ref:`Docker registry mappings <docker_registry_mappings>`, each entry being a ``{"from": ..., "to": ...}`` pair
129145

130146
Unregister
131147
----------
@@ -141,6 +157,173 @@ List registered Deploy Daemons (DaemonConfigs).
141157

142158
Command: ``app_api:daemon:list``
143159

160+
.. _docker_registry_mappings:
161+
162+
Docker registry mappings
163+
^^^^^^^^^^^^^^^^^^^^^^^^
164+
165+
.. versionadded:: 32.0.0
166+
167+
Every ExApp declares in its ``info.xml`` the registry its image is pulled from, usually ``ghcr.io`` or ``docker.io``.
168+
A Deploy Daemon can override those registries so that images are pulled from somewhere else, without any change to the
169+
ExApp itself. This is useful when your servers have no access to the public registries, when you mirror the ExApp
170+
images into a private registry, or when you want to test locally built images.
171+
172+
.. note::
173+
Registry mappings only apply to daemons of the ``docker-install`` type. They have no effect on ``manual-install``
174+
daemons, because those do not pull images.
175+
176+
Finding the registry of an ExApp
177+
--------------------------------
178+
179+
The registry to map is the one in the ``<registry>`` element of the ``<docker-install>`` section of the ExApp's
180+
``info.xml``, which is part of the ExApp source:
181+
182+
.. code-block:: xml
183+
184+
<info>
185+
...
186+
<external-app>
187+
<docker-install>
188+
<registry>ghcr.io</registry>
189+
<image>example-org/exapp_name</image>
190+
<image-tag>1.0.0</image-tag>
191+
</docker-install>
192+
...
193+
</external-app>
194+
</info>
195+
196+
Together these three elements form the image that is pulled, ``ghcr.io/example-org/exapp_name:1.0.0``. To redirect this
197+
ExApp, add a mapping with ``ghcr.io`` as the source registry.
198+
199+
.. important::
200+
Only the registry is replaced. The ``<image>`` and ``<image-tag>`` values are used unchanged, so the image must be
201+
available in your custom registry under exactly the same repository path and tag, in this example
202+
``example-org/exapp_name:1.0.0``. Mirror the image with its original name, for instance:
203+
204+
.. code-block:: bash
205+
206+
docker pull ghcr.io/example-org/exapp_name:1.0.0
207+
docker tag ghcr.io/example-org/exapp_name:1.0.0 registry.example.com/example-org/exapp_name:1.0.0
208+
docker push registry.example.com/example-org/exapp_name:1.0.0
209+
210+
How mappings are applied
211+
------------------------
212+
213+
A mapping is a pair of registry domains: ``from`` is the registry declared by the ExApp, and ``to`` is the registry
214+
that should be used instead. During deployment, at the image pull step, AppAPI compares the ExApp registry with the
215+
``from`` value of each mapping. On the first match, the registry part of the image name is replaced with ``to``, while
216+
the image name and tag stay untouched:
217+
218+
.. code-block:: text
219+
220+
mapping: ghcr.io -> registry.example.com
221+
222+
declared: ghcr.io/example-org/exapp_name:1.0.0
223+
pulled: registry.example.com/example-org/exapp_name:1.0.0
224+
225+
The special target ``local`` does not rewrite the image name. Instead it skips the image pull entirely, and the image is
226+
expected to already be present on the Docker host under its original name, either pulled manually beforehand or built
227+
locally:
228+
229+
.. code-block:: text
230+
231+
mapping: ghcr.io -> local
232+
233+
declared: ghcr.io/example-org/exapp_name:1.0.0
234+
pulled: nothing, the image already present on the host is used
235+
236+
.. warning::
237+
With a ``local`` target, AppAPI cannot pull a missing image. If the image is absent from the Docker host,
238+
deployment of the ExApp fails at the container creation step.
239+
240+
Mappings are stored per daemon in the ``registries`` key of its :ref:`DeployConfig <deploy_config>`, and are
241+
applied to every ExApp deployed through that daemon. Only one mapping per ``from`` registry is allowed, and existing
242+
ExApp containers are not affected: a mapping takes effect the next time an ExApp is deployed or updated.
243+
244+
.. important::
245+
AppAPI does not send registry credentials when pulling images. If your registry requires authentication, log the
246+
Docker daemon into it beforehand with ``docker login``, so the pull can succeed with the stored credentials.
247+
248+
Web interface
249+
-------------
250+
251+
Open the AppAPI admin settings, click the three-dots menu of a Deploy Daemon and select **Docker registries**:
252+
253+
.. image:: ./img/docker-registries-menu.png
254+
:alt: AppAPI admin settings showing the Docker registries entry in the three-dots menu of a Deploy Daemon
255+
256+
In the **Override Docker registries** dialog, the configured mappings are listed, and mappings with the ``local``
257+
target are marked with *Image pull will be skipped*. Click **Add registry override mapping**, fill in the **From** and
258+
**To** fields, and confirm with the **Add** button. To delete a mapping, use **Remove** in the three-dots menu of the
259+
respective list entry:
260+
261+
.. image:: ./img/docker-registries-modal.png
262+
:alt: AppAPI Override Docker registries dialog listing registry mappings with the form to add a new mapping
263+
264+
Add a registry mapping
265+
----------------------
266+
267+
Add a Docker registry mapping to a Deploy Daemon.
268+
269+
Command: ``app_api:daemon:registry:add [--registry-from REGISTRY-FROM] [--registry-to REGISTRY-TO] [--] <name>``
270+
271+
* ``name`` - name of the Deploy Daemon the mapping is added to (e.g. ``docker_install``)
272+
* ``--registry-from`` - ``[required]`` registry declared by the ExApp (e.g. ``ghcr.io``)
273+
* ``--registry-to`` - ``[required]`` registry to use instead, or ``local`` to skip the image pull
274+
275+
The command fails if the daemon does not exist, if a mapping for the same ``from`` registry is already configured, or
276+
if both registries are the same.
277+
278+
* Pull images that ExApps declare on ``ghcr.io`` from a private registry instead:
279+
280+
.. code-block:: bash
281+
282+
sudo -E -u www-data php occ app_api:daemon:registry:add docker_install --registry-from "ghcr.io" --registry-to "registry.example.com"
283+
284+
* Use images that are already present on the Docker host instead of pulling them from ``ghcr.io``:
285+
286+
.. code-block:: bash
287+
288+
sudo -E -u www-data php occ app_api:daemon:registry:add docker_install --registry-from "ghcr.io" --registry-to "local"
289+
290+
Remove a registry mapping
291+
-------------------------
292+
293+
Remove a Docker registry mapping from a Deploy Daemon. Both registries of the mapping must be given, so that the exact
294+
pair is removed.
295+
296+
Command: ``app_api:daemon:registry:remove [--registry-from REGISTRY-FROM] [--registry-to REGISTRY-TO] [--] <name>``
297+
298+
* ``name`` - name of the Deploy Daemon the mapping is removed from (e.g. ``docker_install``)
299+
* ``--registry-from`` - ``[required]`` source registry of the mapping to remove
300+
* ``--registry-to`` - ``[required]`` target registry of the mapping to remove
301+
302+
.. code-block:: bash
303+
304+
sudo -E -u www-data php occ app_api:daemon:registry:remove docker_install --registry-from "ghcr.io" --registry-to "registry.example.com"
305+
306+
List registry mappings
307+
----------------------
308+
309+
List the Docker registry mappings configured for a Deploy Daemon.
310+
311+
Command: ``app_api:daemon:registry:list <name>``
312+
313+
* ``name`` - name of the Deploy Daemon to list the mappings of (e.g. ``docker_install``)
314+
315+
.. code-block:: bash
316+
317+
sudo -E -u www-data php occ app_api:daemon:registry:list docker_install
318+
319+
The mappings are printed as ``from -> to`` pairs:
320+
321+
.. code-block:: text
322+
323+
Configured registries for daemon "docker_install":
324+
- ghcr.io -> registry.example.com
325+
- docker.io -> local
326+
144327
Nextcloud AIO
145328
^^^^^^^^^^^^^
146329

31.2 KB
Loading
145 KB
Loading

0 commit comments

Comments
 (0)