Labels
Perdu builds its page from labels on your containers: whoever writes a service's labels decides what its tile offers, and whoever configures perdu decides what the page shows and how.
Every label perdu reads starts with the namespace, perdu by default and configurable via --namespace, written <prefix> below.
Declaring a service
A container puts a service on the page when it carries <prefix>.enable=true and a service name:
services:
grafana:
image: grafana/grafana
labels:
perdu.enable: "true"
perdu.name: Grafana
perdu.url: https://grafana.example.com
Perdu lists only the containers carrying <prefix>.enable, so that label has to be spelled exactly: a container whose enable label is mistyped is left off the page without a warning, while every other mistyped label under the prefix is warned about.
Perdu also lists stopped containers, so a stopped service stays on the page (Service identity).
A container can declare several services, each a tile of its own (Several services on one container).
The labels
| Label | Required | Localizable | Holds |
|---|---|---|---|
<prefix>.enable |
yes | no | whether perdu reads the container's labels: true or false |
<prefix>.services.<key>.* |
service labels | ||
<prefix>.* |
service labels of the anonymous service | ||
| Service labels | |||
name |
yes | the service's name | |
description |
the tile's second line | ||
url |
where the tile links | ||
icon |
the tile's icon (Icons) | ||
category |
no | the sections the tile is in, comma-separated | |
audience |
no | the groups the tile is shown to, comma-separated; empty is everybody | |
actions.<key>.* |
action labels | ||
| Action labels | |||
name |
yes | an action's name | |
icon |
an action's icon | ||
url |
where an action links | ||
category |
no | an action's sections; if empty, takes the service's | |
audience |
no | the groups an action is shown to; never falls back to the service's |
A service and each of its actions are entities: each is declared by its labels, shown on its own, and set aside on its own when one of its labels can't be used (What happens to a label perdu can't use). An action has no description.
A service's name, description, url and icon, and an action's name, url and icon, can be given per language by adding a locale to the key, as in <prefix>.name.fr=Fou (Locales); enable, category and audience can't.
A container can declare several independent services, each with its own actions and its own tile, by keying the labels that belong to one service under one key: <prefix>.services.<key> (Several services on one container).
Service labels can appear outside the services block and define the anonymous service.
A <key> must match [a-zA-Z0-9_-]+, for both service and action keys: a label whose key holds anything else (including an empty one) is ignored with a WARN and declares nothing.
How a value is read
Every value is trimmed of the spaces around it before anything reads it, so a value of only spaces is an empty one.
Note
This is in contrast with flags, whose value is never trimmed as a whole (Flags); perdu is generally more lenient for entity definitions than it is for its own configuration.
An empty value is a value, and only a label that isn't present is none.
<prefix>.description= gives the service no description, where leaving the label out lets a translated page fall back to another language's description (Locales); an empty value asks for no page, so <prefix>.description.sv= alone generates no Swedish page (Locales).
An optional label left empty is never warned about: <prefix>.icon= gives the tile no icon, quietly.
A list — category and audience — is comma-separated, each element trimmed, so user, admin is user and admin, while Media Server is one category.
An element given twice counts once, and the order you wrote them in is kept (first occurrences win).
There is no way to escape a comma, so an element can't hold one.
An element left empty, as in audience=, or category=Media,,Tools, is a mistake rather than an element to drop, and sets its entity aside with a WARN: audience=, would otherwise publish a service to everyone.
An empty list, <prefix>.audience= or <prefix>.category=, declares nothing, as leaving the label out does.
A key is matched exactly as written, its locale apart: <prefix>.Name is not <prefix>.name, and <prefix>.actions.Foo.name and <prefix>.actions.foo.name are two actions.
A misspelled key is ignored with a WARN naming it, and the service or action it names may then be set aside for the label it misses, with a second WARN.
enable
<prefix>.enable says whether perdu reads the container's other perdu labels at all, whichever service they declare, and declares nothing by itself: a container carrying only enable puts nothing on the page.
It takes true or false, and the other spellings Go reads as booleans: 1, t, T, TRUE, True, and 0, f, F, FALSE, False.
falseswitches the container off without removing its labels, silently.- An empty value is refused, as is anything outside that set, and sets the container's services aside with a
WARN: writing the bare key, as inlabels: ["perdu.enable"], could mean on or off, so perdu asks you to write which. enablenever takes a locale;<prefix>.enable.fris ignored with aWARN.
name
An entity's name, shown as its tile's or its line's heading.
It must be non-empty wherever it is given, and must have a value the page falls back to — <prefix>.name, or <prefix>.name.<default-locale> — so that every page has one (Locales); otherwise the entity is set aside with a WARN.
description
The tile's second line, at most five lines on the page (The template). Without one, the tile shows its URL there.
url
Where a tile or an action links. Without a usable one, a service's tile links nowhere and the page shows it dimmed, while an action isn't shown at all (The template).
Perdu accepts two forms:
- an absolute URL with an
http,httpsormailtoscheme, anhttporhttpsone naming a host:https://jellyfin.example.com,mailto:admin@example.com. No other scheme is accepted (ssh:,vnc:,obsidian:, etc.) because perdu keeps Go's template escaping rather than bypassing it. That escaping turns any other scheme into an inert link, which also keeps ajavascript:link harmless, whoever wrote the label; - a root-relative path, with no scheme or host, beginning with
/and holding no backslash:/plex/, for a service served on a path of the same host as perdu.
Anything else is unusable: another scheme, a path not beginning with / such as plex, which would resolve against the page's own address /l/en/, or a value perdu can't parse.
An unusable value isn't an error: a service's tile stays, linking nowhere, an action is left off the page, and a WARN naming the label says why on every build until you fix it.
Perdu parses a URL more strictly than a browser, so a URL your browser follows can still be unusable here. These are the spellings it refuses, and the forms that work:
| Refused | Write instead |
|---|---|
a % that starts no escape, in the path or after #: https://example.com/100% |
%25: https://example.com/100%25 |
| a tab or another control character | its escape, %09 for a tab |
a space in the host: https://exa mple.com/ |
the host without it |
an escape spelling a letter, a digit or other ASCII in the host: https://ex%41mple.com/ |
the character itself: https://exAmple.com/ |
a port that isn't a number: https://example.com:port/ |
the port's number |
an IPv6 host missing its ]: https://[::1/ |
https://[::1]/ |
https:example.com, which names no host |
https://example.com |
a value beginning with //: //host/path, ///host |
https://host/path |
a backslash in a root-relative path: /a\b |
/a/b |
A % in the query, after ?, is taken as written.
category
The sections a tile is in: each value names a section, and a tile is drawn once in every section its entity names. Perdu takes a value as a key that groups tiles, never as text to show: the built-in template shows no category value anywhere, telling its sections apart by a line between them.
perdu.category=Media
perdu.category=Media,Downloads
Unlike audience, a category value takes any character but a comma.
In this release the named sections are grouped by exact matching (Media and media are two sections) and follow one another in the code-point order of their category values, the same on every page; that order is kept only while sections show no heading, so don't build on it.
A category can't take a locale: <prefix>.category.fr sets its entity aside with a WARN.
A value starting with ~ names a placement rather than a section: a place the page's template defines.
The built-in template defines two:
~default, the uncategorized section, which comes first, before the named sections. A stack that sets nocategoryat all shows one section holding everything; as you name categories, the still-uncategorized tiles stay above them. A service whose category is left empty or unset is placed at~default, as if it had declared it. For an action, an empty or unset category makes it take its parent service's.~admin, the administration section, which comes last. It is a place for what most viewers use least, and it places without restricting:audiencedefines who sees a tile there, as anywhere else. To show an administration service to administrators only, pair the two:
perdu.category=~admin
perdu.audience=admins
An action placed there under a service placed elsewhere is a tile of its own in it.
Placements compose with sections: category=~default,Media puts a tile in both.
Any other placement, a mistyped one such as ~admni included, shows nowhere in the built-in template, and every build logs an INFO line naming the placement and the entities placed there.
audience
The groups a tile is shown to: a viewer sees it when any one of their groups is among its values.
perdu.audience=admins
perdu.audience=family,friends
Warning
Hiding a tile is presentation, not access control. Every page holds every tile, whoever views it: a viewer without JavaScript, or reading the page's source, sees them all. A service has to protect itself.
Each value is a token, and must match [a-zA-Z0-9._-]+; identity-provider groups such as team.admins work.
A value holding anything else (including spaces) sets its entity aside with a WARN, rather than being dropped: dropping the only value would show the tile to everyone.
An audience can't take a locale: <prefix>.audience.fr sets its entity aside with a WARN.
A tile with no audience is shown to everyone.
There is no way to show a tile to nobody: an empty list declares no restriction, as leaving the label out does.
Tip
audience declares restrictions, no audience means no restriction.
A viewer's groups come from --audience-expr (Per-viewer data).
With no rule computing them, every viewer sees every tile, whatever its audience.
Each build then logs an INFO line naming the entities that declare one, since their labels ask for filtering that no rule provides.
Tip
A rule that gives a viewer no groups is not the same as no rule: that viewer sees only the tiles without an audience.
To show a tile to viewers with no groups, have your --audience-expr give them a group of their own, such as guest, and list it in audience.
Actions
An action is a link a service offers beside its own, such as a settings page or a "Request access" form, declared among its service's labels under actions.<key> (The labels), here on the anonymous service:
perdu.actions.password.name=Change password
perdu.actions.password.url=https://auth.example.com/password
perdu.actions.password.icon=fa:solid-key
The key identifies the action among its service's, is never shown, and takes the characters every key does (The labels). A service's actions show in the code-point order of their keys: digits before capitals before lower case.
Tip
Use keys such as 1-sessions and 2-password to set an order independent of the words in them.
An action is nested or standalone, section by section. In a section that also holds its service, it is drawn inside the service's tile, as a line under its head; in a section that doesn't, it is a tile of its own, which shows its service's name as its second line. An action that declares no category takes its service's, so it is nested in each of its service's sections; one declaring a category its service doesn't share has a tile of its own in that section.
Tip
To put an action in the uncategorized section while its service has categories, use category=~default.
An action's audience is its own.
Nested, it is hidden whenever its service is, whatever it declares, since it is drawn inside the service's tile; standalone, nothing contains it, so it is restricted by its own audience alone.
Tip
An administrators-only service can offer a "Request access" action that everyone sees, in a section the service isn't in:
perdu.category=Admin tools
perdu.audience=admins
perdu.actions.access.name=Request access
perdu.actions.access.url=https://example.com/access
perdu.actions.access.category=Tools
Several services on one container
A container's labels can declare several services, each a tile of its own: a container providing several functions gets a tile for each.
services:
immich:
image: ghcr.io/immich-app/immich-server
labels:
perdu.enable: "true"
perdu.name: Immich
perdu.url: https://photos.example.com
perdu.services.grandma.name: Photos for Grandma
perdu.services.grandma.description: No internet? The photos are also on the USB stick in the drawer under the TV.
The services of one container are independent: each declares its own labels and takes none from another, the anonymous service's included, and each is set aside on its own, never due to another service of the container.
Only <prefix>.enable is shared, as the container's switch for all of them.
The anonymous service exists only where a label outside every block does: a container carrying only <prefix>.services.<key> blocks doesn't declare it.
Adding a block to a container changes nothing for the services already on it, including those its image declares (Labels an image declares).
Unlike for actions, the service's key is not used to sort entities; it is used to identify a service in logs (Reading the logs) and as a source of deterministic pseudorandomness for the service's tile.
Service identity
Several containers can declare the same services: most often the replicas of a scaled compose service.
Perdu gathers the containers carrying <prefix>.enable into workloads by the values of the labels --workload-labels lists, by default Compose's project and service labels, so a compose service is one workload however many containers it runs, and its labels declare its (perdu) services (How perdu works).
A service is identified by its workload and its key, the anonymous service's being empty, and an action by its service and its own key.
- A container missing any of those workload labels is never on the page, and unless its own
enableisfalse, perdu logs anINFOline naming it and the labels it lacks. A container you start withdocker run -l perdu.enable=true, outside Compose, lacks the Compose labels the default lists. - A workload's containers rank by state: running first, then unavailable, then stopped, and only those of the highest rank present define it, and with it every service it declares. So a stale stopped container can't hide the one running, and a replacement restarting in a loop leaves the running container's labels on the page; when none is live (running or unavailable), the stopped ones define the workload and its services stay on the page.
In order to limit the staleness of the information displayed on a page and avoid flicker, the ranks have different rules for picking the defining containers:
| Rank | State | Defines a workload |
|---|---|---|
| 1 | running |
The oldest container |
| 2 | unavailable: paused, restarting |
The oldest container |
| 3 | stopped: created, exited, dead, being removed |
The newest container |
If there is a tie, i.e. several oldest or newest containers created in the same second, conflicting labels set the workload's services aside with a WARN naming them, unless they all set enable to false (whatever else they declare): the workload is then off, as one container switching it off would leave it.
Otherwise, perdu names the containers of that rank whose labels differ from those defining the workload: at INFO while its services are on the page, or where a newer live container would switch on a workload that is off, so that a service you just enabled or fixed says why it doesn't show yet; at DEBUG otherwise, for a workload left off whatever the container declares.
During a redeploy, the new live container waits for the old one to stop (it counts as running until its process exits); a new container still ignored after that differs from another live container of its workload, older than itself.
The older one may be a one-off container run from the service's definition before the redeploy (such as one docker compose run starts), which keeps the old labels on the page while it runs; otherwise, the difference is a mistake worth fixing.
Once the workload has stopped, the container ignored is an older one left behind, which you can remove.
- A workload defined only by stopped containers gets one more check.
Perdu then looks for a live container of the same workload that carries no
<prefix>.enable— what a redeploy that removed the labels leaves — and if it finds one, leaves the workload's services off the page (with anINFOline) so that removing a container's labels removes its tiles. Each such workload costs an extra docker call per build.
With --workload-labels empty, every container is a workload of its own, identified by its container ID, and none of the above applies.
Starting or stopping a container starts no build, so that a container restarting in a loop doesn't rebuild the page every few seconds; where it changes which containers define a workload, the page follows on the next build, or on a refresh (Deploying perdu).
On the other hand, a container carrying <prefix>.enable that perdu ignores, or whose services it sets aside, still starts a build when it is created, updated or removed, and that build runs to completion even though it produces the same pages (How perdu works).
Labels an image declares
A container's labels include those its image declares, and perdu reads them as the container's own: image and container labels are merged by docker and indistinguishable when read from containers.
An image declaring <prefix>.* labels therefore puts itself on the page as they describe — and can add locales, make every viewer's browser contact a server it names, make perdu fetch the icons it names from your remotes' hosts, and carry another workload's values for the workload labels beside perdu labels of its own, which can put its labels on that workload's tiles or set its services aside (Service identity).
You can override an image's labels on the container, but not remove them; Compose's !reset doesn't reach them.
The levers are <prefix>.enable=false on the container, a --namespace the image doesn't use, restricting generated locales, and not running the image.
When perdu checks a label
Perdu checks your labels in two steps, on every build.
Reading the labels decides what exists: which services and actions stand, which pages there are, and the value each page shows for each field, its own locale's or the one it falls back to (Locales). A problem found here sets an entity aside or ignores a key.
Rendering the pages checks the values chosen for each page: a url's scheme and shape, an icon's form, whether a library has the icon.
A value that fails leaves its field empty on the pages that show it, and changes nothing else: the entity and the page stay (Locales).
What happens to a label perdu can't use
Perdu never fails the page over a label.
Each problem costs as little as it can, and is logged at WARN on every build while it lasts, once per build per label, naming the label, the entity carrying it and the pages it affects, so that it stays in recent logs.
These set an entity aside, logged as service excluded or action excluded, or as services excluded for a workload's; a service set aside takes its actions with it, while an action set aside leaves its service in place; neither remove locales:
- an
enablethat is empty or isn't a boolean, a mix oftrueandfalseamong a workload's containers, or a workload's containers declaring different labels, which sets aside every service the workload declares; - a
nameleft empty, or with no value to fall back to; - an
audiencevalue outside its characters; - an empty element in a
categoryoraudiencelist; - a
categoryoraudiencekey with a locale; - two keys for one field whose locales are one locale spelled two ways, as
<prefix>.name.fr-chand<prefix>.name.fr-CH, which sets aside the entity carrying the field.
These are ignored, and the entity stays, logged as container labels ignored: a key perdu doesn't know under the prefix; a service or action key outside its character set, whose label declares nothing; a locale on enable; and logged as labels ignored, a locale perdu can't use (Locales).
These leave a value empty, and the entity stays, logged as unusable value: a url or an icon perdu can't use, and a data: icon it can't decode (Icons); and logged as icon unresolved, an icon reference no library answers.
Note that the entity not being set aside does not mean it will be shown on the page: the template is free to deal with an entity as it sees fit; this release's built-in template does not show actions with an unusable url, just as if it were empty.
Nothing is logged for a label left out, an optional label left empty, or enable=false.