Skip to content

Practical remote use

The remote rendering scenario for Uptick involves two main components, a workstation and a server.

Workstation

The workstation is a client machine on which source material is maintained that needs ‘upticking’ to something that is viewable in a web browser.

The source material is stored on the local filesystem of the workstation, and edited there using standard desktop tools like Kate and GIMP.

Server

The server is a separate Linux machine that can be reached via SSH from the workstation. It may wel be a virtual machine that is run on the workstation.

Rendering

Source material tends to be developed incrementally. New (Markdown and media) files get added, existing files are modified, extended or removed.

After a related set of changes has been made, the Uptick infrastructure can be asked to rerender the offline and/or online ‘site content’.

In the remote mode of Uptick, (re)rendering is requested by running a workstation-local script. Successful execution of this script results in updates being made to equally workstation-localoffline, online and cache subdirectories.

Local scripting

For the remote rendering scenario, the workstation part of Uptick consists of a single bash script that delegates to a situation-specific appendix of sorts.

The render script transfers local content to the server, calls upon the server-side elevate script, and transfers remote content back to the workstation.

As it is using rsync ‘over SSH’ as well as ssh directly, the render script will need to know what server to address, as what user to authenticate to it, and what to use as the server-side equivalent of the local Uptick space directory.

These details are expressed in a render.ENV file which is expected to be located alongside the render script as run from the bash command line.

The render script has been set up in such a way that there should be no need to ever change it – for any individual Uptick-based documentation initiative. The core script may be treated as a given. Anything specific to the local situation will be placed in the .ENV file.

Script placement

For a remote Uptick endeavor, an Uptick space directory gets created on the workstation. At minimum, this space directory contains a source subdirectory and either an offline subdirectory, an online subdirectory or both. In the space directory, a cache subdirectory may be created as well – initially empty, as are the offline and/or online subdirectories.

The render script also expects to be located immediately below the space directory. Within the space directory, the render script may make an appearance as an actual file or – more likely – a symbolic link to the actual render script.

The render.ENV file that gets included by the render script needs to be deposited next to the render file as it is being run – in the shape of a actual script file or a symbolic link to one.

Combining all the ingredients, a newly constructed Uptick space directory might look like this:

Topic/
  ├─ cache/
  ├─ offline/
  ├─ online/
  ├─ source/
  │    ├─ docs/
  │    │    └─ index.md
  │    └─ mkdocs.yml
  ├─ render -> /path/to/render
  └─ render.ENV

The content of the render.ENV file (which contains bash statements but need not be executable) would be something like...

REMOTE_HOST=10.5.6.7
REMOTE_USER=root
REMOTE_SPACE=/root/uptick

REMOTE_HOST is the hostname, fully qualified DNS name or IP address of the machine on which the server-side infrastructure of Uptick (which includes [Material for] MkDocs) has been installed.

REMOTE_USER is the ID, ‘username’ of a remote user on the server, which can be SSHd into from the workstation. The remote user account is expected to have been decorated with a public key in its ~/.ssh/authorized_keys file, and the corresponding private key to have been made available to an ssh-agent on the workstation.

As a result, the local user on the workstation should have the ability to run a command like...

ssh root@10.5.6.7 date

...without getting prompted for a password.

REMOTE_SPACE is the path to a filesystem directory that on the server will act like the remote equivalent of the workstation-side Uptick space directory. It is recommended for this to be an absolute path.

The remote space needs to either exist as a server-side filesystem directory, or not exist at all – in which case it will get created by the render script.

Script execution

When the in-space render script is run, the script issues multiple ssh and rsync commands. Assuming both offline and online output is being requested (by virtue of both an offline and an online subdirectory existing in the workstation-local space directory), the output of an initial render run could look like this:

mkdir: created directory '/root/uptick'
mkdir: created directory '/root/uptick/source'
mkdir: created directory '/root/uptick/cache'
mkdir: created directory '/root/uptick/offline'
mkdir: created directory '/root/uptick/online'
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /root/uptick/offline
INFO    -  Downloading external file: https://unpkg.com/mermaid@11/dist/mermaid.
min.js
INFO    -  Downloading external file: https://unpkg.com/iframe-worker/shim
INFO    -  Documentation built in 0.83 seconds
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /root/uptick/online
INFO    -  Documentation built in 0.54 seconds

A later rerun of the render script might result in reduced output, as in...

INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /root/uptick/offline
INFO    -  Documentation built in 0.52 seconds
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /root/uptick/online
INFO    -  Documentation built in 0.51 seconds

This time, the remote space directory (/root/uptick) and the necessary subdirectories (source, cache, offline and online) already exists. External downloads are no longer necessary, since the material that was downloaded in the preceding run will have ended up in the server-side cache subdirectory.

That content would have been transferred to the workstation-side cache subdirectory, and in the second run sent back over the server for good measure. Where it was present already, allowing a reduction in the amount of material that would have required transportation.

After a successful render run, the local offline and online subdirectories will have been filled, or updated, with up-to-date HTML projections of the source material.

In the offline subdirectory, there will be an index.html file that can be opened with a workstation-local web browser.

The content of any online subdirectory is more suitable for transfer to a web server. If such a server could be found on IP address 10.5.7.8 and happened to be a Red Hat Enterprise Linux machine running Apache, a command like...

rsync --archive --hard-links --progress --delete \
    /path/to/Topic/online/ \
    root@10.5.7.8:/var/www/html/

...might be used to get the Uptick-rendered material published.