Production deployment
This page is for maintainers of omicsbase.utu.fi. It describes the layout and the usual procedures. It names no addresses, accounts or keys; keep those in a private place.
Hosts
| Host | What it serves |
|---|---|
omicsbase.utu.fi |
The notes app (LibreChat). Also /omics-engine/… (notes engine files), /docs/ (these docs), and robots.txt and sitemap.xml. |
openhands.omicsbase.utu.fi |
Reports. It carries the tunnels from Reports sessions, the router’s open and close links, and each user’s requests to their own session. Without a Reports session it answers 404. |
admin.omicsbase.utu.fi |
The LibreChat admin panel. |
Caddy serves all three with HTTPS, using HARICA certificates. Users sign in with Google or with SAML through the Haka federation (University of Turku included) and eduGAIN. New SAML accounts from utu.fi get the UTU role and all others the USER role, which Google accounts also get. Each role’s model list and settings are stored in MongoDB (configs collection) and override librechat.yaml. LibreChat verifies the Haka and eduGAIN metadata in a child process every 6 hours and caches the result under data/saml-federation.
What runs where
The VM is a CSC cPouta virtual machine. The checkout lives in /srv/omicsbase/omicsbase.
- Docker Compose runs the project
librechat: LibreChat (api), MongoDB, Meilisearch, the file-search services (vectordb,rag_api), the admin panel and the fallback notes engine. - Outside Compose, the VM runs:
- Caddy, the web server (a systemd service).
roihu-router, the router for Reports sessions (a systemd service).roihu-relay, the chisel server that Reports sessions tunnel to (a systemd service).- A nightly cron job that rebuilds the sitemap.
LUMI-K runs the notes engine as a gateway, shared worker pods that host many notes’ R sessions, and pods of their own for heavy notes. The manifest is deployment/lumi-k/engine.yaml; its comments explain the sizes.
Roihu runs each user’s Reports job, in that user’s CSC project.
For how requests flow between these, see How OmicsBase fits together.
Configuration files
| On the VM | Comes from | Holds |
|---|---|---|
librechat/.env |
.env.example |
Secrets, image tags, hosts, Roihu settings. Not in Git. |
librechat/librechat.yaml |
deployment/librechat.yaml |
Model endpoints, the notethreads server, model specs. |
librechat/docker-compose.override.yml |
deployment/docker-compose.override.yml |
The production additions to LibreChat’s Compose file. |
/etc/caddy/Caddyfile |
deployment/Caddyfile.production |
The web server rules. |
The files on the VM are copies. The live Caddyfile has the real host names and certificate settings, so it is kept in step with deployment/Caddyfile.production by hand. When you change a rule, change both.
Settings in librechat/.env
The hosts the browser sees:
DOMAIN_CLIENT=https://omicsbase.example.org
OMICSBASE_APP_HOST=omicsbase.example.org
OMICSBASE_OPENHANDS_PUBLIC_URL=https://openhands.omicsbase.example.org
OMICSBASE_WORKSPACE_HOST=openhands.omicsbase.example.org
OMICSBASE_ENGINE_PUBLIC_URL=https://omicsbase.example.org/omics-engine
OMICSBASE_ADMIN_HOST=admin.omicsbase.example.org
The secrets and links between the parts:
| Setting | What it is |
|---|---|
OMICSBASE_AUTH_SECRET |
Shared by LibreChat and Reports. Generate it on its own, never reuse a LibreChat JWT secret. |
OMICSBASE_ENGINE_SECRET |
Shared by LibreChat and the notes engine. It must equal the engine’s secret on LUMI-K. |
OMICSBASE_ENGINE_URL |
Where LibreChat sends note cells. Empty means the VM’s own engine. |
ROIHU_ROUTER_SECRET |
The router’s admin secret, which the router keeps in its state folder. |
ROIHU_RELAY_FINGERPRINT |
The relay’s TLS fingerprint. The relay prints it when it starts. |
ROIHU_IMAGE_TAG |
The Reports image that Roihu jobs and own computers use. |
OMICSBASE_LIBRECHAT_IMAGE |
The LibreChat image to run. |
To generate a secret:
openssl rand -hex 32Run Compose on the VM
All Compose commands run from the checkout, with the same files. For example, to recreate LibreChat:
cd /srv/omicsbase/omicsbase
docker compose --project-directory "$PWD/librechat" --env-file librechat/.env -p librechat \
-f librechat/docker-compose.yml -f librechat/docker-compose.override.yml \
up -d --no-deps --force-recreate apiDeploy a new LibreChat image
The LibreChat image is built on the VM. Several server files are not taken from the image: the override mounts them from the checkout in librechat/ (see the volumes of api in docker-compose.override.yml). The image and the checkout must therefore be at the same fork commit.
Note the current image tag (
OMICSBASE_LIBRECHAT_IMAGEinlibrechat/.env) and the current commit of thelibrechat/checkout. You need both to roll back.Export the new fork commit into a separate build folder, so the live checkout is never half-switched:
mkdir -p <build folder> git -C librechat archive <commit> | tar -x -C <build folder>Start the build under systemd, so it keeps running if your SSH connection drops:
sudo systemd-run --unit=build-librechat --working-directory=<build folder> sh -c \ 'docker build --progress=plain --build-arg BUILD_COMMIT=<commit> -t omicsbase-librechat:<short commit> . > build.log 2>&1; echo EXIT=$? >> build.log'Check whether it is still running:
systemctl is-active build-librechatIt prints
activewhile it runs. A LibreChat build takes about 40 minutes.When it has stopped, read the end of the log:
tail -n 3 <build folder>/build.logThe last line must be
EXIT=0.Move the
librechat/checkout to the same commit.Set
OMICSBASE_LIBRECHAT_IMAGE=omicsbase-librechat:<short commit>inlibrechat/.env.Recreate
apiwith--force-recreate, as in Run Compose on the VM. A plain restart is not enough: a mounted single file keeps pointing at the old file until the container is recreated.Check the server log for the line that lists the
notethreadstools:docker logs LibreChat 2>&1 | grep "Tools:"It must list the tools, such as
execute_r_cell. If it is missing, notes have no tools.In the browser, run an R cell in a note and open Reports.
Do not run git pull on the VM checkout as a deployment step. Move it to an exact commit.
Notes engine on LUMI-K
The LUMI-K image must run as a random non-root user. It is the released engine image with deployment/rahti/Dockerfile on top. The plain engine image fails there.
Make the release, so that CI has pushed
ghcr.io/0xmuluh/omicsbase-engine:<version>(Make a release).On the VM, sign in to LUMI-K with
oc login, then sign root’s Docker in to the LUMI-K registry:sudo docker login -u "$(oc whoami)" -p "$(oc whoami -t)" registry.apps.v1.lumi-k.euBuild, test and push the LUMI-K image from the VM checkout:
sudo scripts/push_engine_lumik.sh <version>It pulls the release, adds the LUMI-K layer, starts it as a random user in group 0, pushes it and prints its name,
registry.apps.v1.lumi-k.eu/omicsbase-utu/omicsbase-engine:lumik-<version>.Switch the engine to it and wait for the rollout:
oc set image deploy/omicsbase-engine engine=<printed name> oc rollout status deploy/omicsbase-engine --timeout=15mDelete the note workers. The gateway starts new ones from its own image:
oc delete pod -l omicsbase-worker=trueOpen notes restart their R session once and restore their saved objects.
To roll back, set the previous image in step 4 and delete the workers again.
The engine’s secret on LUMI-K is a Kubernetes secret, created separately (see the header of engine.yaml). If you change OMICSBASE_ENGINE_SECRET, change it on both sides.
Switch notes between LUMI-K and the VM
Three settings decide where notes run:
OMICSBASE_ENGINE_URLinlibrechat/.env.- The
urlofnotethreadsinlibrechat/librechat.yaml(the VM engine ishttp://engine:8001/sse). - The
@engine_runsrule in the Caddyfile, which sends plot requests to LUMI-K.
Change all three together, then recreate api and reload Caddy:
sudo systemctl reload caddyReports on Roihu
The router and the relay run as systemd services on the VM. The router keeps its routes, relay credentials and secrets in /srv/omicsbase/roihu-relay.
Update the router
Copy the current file to a backup next to it.
Copy the new
deployment/roihu/roihu_router.pyinto place.Restart the service:
sudo systemctl restart roihu-router
Roll out a new Reports image
From the repository root, build the Reports image. This also builds the interface into
openhands/build/, which the next step copies:python3 scripts/build_openhands.py --context defaultBuild the Roihu image on top of it:
docker build -f deployment/roihu/Dockerfile --build-arg BASE_IMAGE=omicsbase-openhands:dev \ -t ghcr.io/0xmuluh/omicsbase-reports:<tag> .Tags follow the pattern
v<OpenHands version>-roihu<n>, for examplev1.41.0-roihu4.Push it:
docker push ghcr.io/0xmuluh/omicsbase-reports:<tag>On Roihu, submit the Slurm job
deployment/roihu/pull_image.sbatchwithREPORTS_TAG=<tag>andREPORTS_IMAGES=<folder>set. It turns the image into an Apptainer file,omicsbase-reports_<tag>.sif.On a Roihu login node, publish that file:
deployment/roihu/publish_sif.sh <path to .sif> <tag>It asks for a GitHub user and a token with
write:packages, and ends withPublished oras://ghcr.io/0xmuluh/omicsbase-reports:<tag>-sif. Each project’s first launch then downloads this one file and skips the conversion.Set
ROIHU_IMAGE_TAG=<tag>inlibrechat/.envand recreateapi.
Each CSC project gets the new image on its first launch after the change. The old image files stay in the projects’ images/ folders.
Search engines
robots.txtand the search-console verification file come fromdeployment/seo/. They are copied to/srv/omicsbase/seo, where Caddy serves them.sitemap.xmllists the front page and every public note.scripts/build_sitemap.shwrites it to/srv/omicsbase/seo/sitemap.xmlevery night at 03:15 UTC, from cron.- To list new public notes the same day, run the script by hand on the VM. It ends with
<n> examples written to /srv/omicsbase/seo/sitemap.xml. robots.txtalso points to the docs’ own sitemap.
Publish the docs
Caddy serves /docs/ from /srv/omicsbase/docs. scripts/publish_docs.sh fills that folder.
You need Quarto 1.11 or later, gh, rsync, and SSH access to the VM.
From the repository root, publish the current docs:
OMICSBASE_VM=<user>@<host> scripts/publish_docs.shIt ends with:
Published: https://omicsbase.utu.fi/docs/For a release, add the version. The script also keeps a copy at
/docs/<version>/:OMICSBASE_VM=<user>@<host> scripts/publish_docs.sh <version>
Set OMICSBASE_SSH_KEY to choose a key file. The script rebuilds the changelog, renders with the publish profile and stops if llms.txt is missing. It replaces the top level of /docs/ and keeps the release copies. The release copies have no sitemap.xml, robots.txt or llms.txt, so the docs sitemap lists only the current docs.
Roll back
Prepare the way back before every change:
- Before you edit a file on the VM, copy it next to itself with a dated suffix, for example
Caddyfile.bak-<yyyymmdd>-<what>. - Keep the previous image. Note its tag and the matching checkout commit.
To go back:
| What changed | How to undo it |
|---|---|
| LibreChat | Set OMICSBASE_LIBRECHAT_IMAGE back, move the librechat/ checkout back to the old commit, and recreate api. |
| A config file | Restore the backup, then recreate api or reload Caddy. |
| The Caddyfile | Restore the backup and run sudo systemctl reload caddy. |
| The router | Restore the backup and run sudo systemctl restart roihu-router. |
| The engine on LUMI-K | Set the previous image in engine.yaml and apply it, or switch notes to the VM engine (see Switch notes between LUMI-K and the VM). |
| The Reports image | Set ROIHU_IMAGE_TAG back and recreate api. |
After any change or rollback, check:
- You can sign in.
- A note runs an R cell and shows its plot.
- The
notethreadstools appear in the LibreChat log. - A public note opens without signing in.
- Reports opens.