# Block registry

Copy the Block registry to an HTTPS service of the company and point the Desktop App and the Backend to it.

The Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) and the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.) read the Block registry (A service from which the Desktop App downloads Blocks. MiLaboratories runs the main one; a company can add its own.) of MiLaboratories, `https://blocks.pl-open.science/`. The Desktop App gets the Blocks (A small application for one step of an analysis, for example the import of reads or clustering. It can combine several tools.), and the Backend gets the workflow (The part of a Block that runs in the Backend. It starts the tools on the data and collects the results. Users do not edit it.) template packs of the Blocks. A mirror is necessary when the company does not let the computers of users or the Backend connect to this host. The mirror is an HTTPS service that gives the same files at the same paths below its own address. It must serve the Desktop App on each computer and the Backend.

The Desktop App reads the registry when users add or update a Block, and when it opens a project and does not have the interface of a Block in its cache. Thus keep the mirror available for as long as Platforma runs, and keep its address: a project keeps the address of the registry that each of its Blocks came from.

The registry is a tree of static files:

- `v2/overview.json`: the list of all Blocks and their versions;
- `v2/<organization>/<name>/<version>/manifest.json`: the description of one Block version, with the list of its files (`files`);
- the files of each Block version, in the same folder as its `manifest.json`;
- `kinds/<organization>/<name>/overview.json`: the versions of the Blocks of one kind.

The Desktop App reads files of all the Blocks in `v2/overview.json` when it shows the list of Blocks. Thus copy the full registry: a copy of some Blocks only, with the original list, does not work. The files of a Block version do not change, so a new copy only adds the new versions. For a registry of the Blocks that the company develops, see [Own Block registry](/configuration-block-registry/).

1. Make an HTTPS service of the company for the mirror, for example a web server or a bucket behind HTTPS, at an address such as `https://blocks-mirror.example.com/`. The computers of users and the Backend must have access to it.

2. Copy the registry into a folder, with the same paths.

   **Example:**

   A script that copies the registry with `curl` and `jq`:

   *copy-blocks.sh*

   ```bash
   #!/usr/bin/env bash
   # Copies the Block registry of MiLaboratories into the folder $1, with the same paths.
   # Run it again to add the new Block versions.
   set -euo pipefail
   src="https://blocks.pl-open.science"
   dst="$1"
   get() { mkdir -p "$(dirname "$dst/$1")"; curl -fsS -o "$dst/$1" "$src/$1"; }


   new="$(mktemp)"
   curl -fsS -o "$new" "$src/v2/overview.json"
   jq -r '.packages[] | "\(.id.organization)/\(.id.name) \(.allVersions | join(" "))"' "$new" |
   while read -r pkg versions; do
     get "v2/$pkg/overview.json"
     for v in $versions; do
       [ -f "$dst/v2/$pkg/$v/manifest.json" ] && continue   # a version does not change
       mkdir -p "$dst/v2/$pkg/$v"
       curl -fsS -o "$dst/v2/$pkg/$v/manifest.tmp" "$src/v2/$pkg/$v/manifest.json"
       for f in $(jq -r '.files[].name' "$dst/v2/$pkg/$v/manifest.tmp"); do
         get "v2/$pkg/$v/$f"
       done
       mv "$dst/v2/$pkg/$v/manifest.tmp" "$dst/v2/$pkg/$v/manifest.json"
     done
     kind=$(jq -r '.description.kind // empty' "$dst/v2/$pkg/${versions##* }/manifest.json")
     if [ -n "$kind" ]; then
       k="${kind#@*/}"; k="${k%@*}"                  # <organization>.<name>.kind
       get "kinds/${k%%.*}/$(cut -d. -f2 <<<"$k")/overview.json"
     fi
   done
   mkdir -p "$dst/v2"
   chmod 644 "$new"
   mv "$new" "$dst/v2/overview.json"                 # last: the list never points to missing files
   ```

   Then publish the folder on the HTTPS service, with the same paths below its address. Run the copy again at regular intervals, so that users get the new Block versions.

3. Check that the mirror gives the files:

   ```sh
   curl -fsS https://blocks-mirror.example.com/v2/overview.json | jq '.packages | length'
   ```

   Result: the number of Blocks is the same as in `https://blocks.pl-open.science/v2/overview.json`.

4. In the Desktop App on each computer, open the settings, turn off **Use Global Access Registry**, and set **Override Main Registry** to the address of the mirror, for example `https://blocks-mirror.example.com/`. See [Block registries in the Desktop App](/configuration-registries/#block-registries-in-the-desktop-app).

5. Point the Backend to the mirror with the option `--blocks-registry-url`, for example `--blocks-registry-url=https://blocks-mirror.example.com/`. In Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.), give it in the Helm value `extraArgs` or in the input `backend_service.extra_args` of `platforma-tf-services`. In Single Server mode (The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster.), give the option or the environment variable `PL_BLOCKS_REGISTRY_URL`. Then restart the Backend. See [Block registry mirror for the Backend](/configuration-registries/#block-registry-mirror-for-the-backend).

6. Add a Block to a project.

   Result: the Desktop App shows the Blocks of the mirror, and the Block opens.

The Blocks run tools on the Backend: the Backend still needs the software images and the assets of the Blocks. See [Software images of the tools](/registries-mirroring-tool-images/) and [Static assets](/registries-mirroring-assets/).

## Next

- [Registries](/configuration-registries/)
- [Install in custom infrastructure](/install-custom-infrastructure/)

Source: https://docs.platforma.bio/registries-mirroring-block-registry/
