Install automation with blueprints¶
A blueprint is a JSON file that describes an Omeka S instance: the modules and themes it needs, the
files to place in it, the vocabularies and resource templates to import, the users, the sites and the
settings. blueprint:deploy reads it and runs the omeka-s-cli commands that bring an instance to that
state. With the database credentials on the command line, the same command also downloads and
installs Omeka S, so one command takes an empty server to a working site.
The format is the shared Omeka S blueprint specification, which documents every key. This page explains how omeka-s-cli applies a blueprint; the commands and their options are on the Blueprints commands page.
Write a blueprint¶
This blueprint, saved as ~/blueprints/site.blueprint.jsonc like the other examples on this page,
sets up a small collection site:
{
// lets your editor complete and check the file
"$schema": "https://omeka-s-contrib.github.io/omeka-s-blueprints/schema/v0/blueprint-schema.json",
"meta": {
"title": "Collections site",
"description": "A small Omeka S instance for an object collection."
},
// used by the core phase only; the password comes from --admin-password
"install": {
"title": "Digital Collections",
"locale": "en_US",
"timezone": "Europe/Brussels",
"admin": { "name": "Site Admin", "email": "admin@example.org" }
},
"modules": [
// a shared list, replaced in place by its entries
{ "$import": "./shared/modules.jsonc" }
],
"themes": [
"default"
],
"vocabularies": [
{
"prefix": "coll",
"namespaceUri": "https://example.org/ns/collection#",
"label": "Collection",
"source": "./vocabularies/collection.ttl",
"format": "turtle"
}
],
"resourceTemplates": [
{ "source": "./templates/book.json" }
],
"users": [
// no password: the editor sets one with "Forgot password"
{ "email": "editor@example.org", "username": "Collection Editor", "role": "editor" }
],
"sites": [
{
"title": "Collections",
"slug": "collections",
"theme": "default",
"setAsDefault": true,
"permissions": [ { "user": "editor@example.org", "role": "editor" } ]
}
],
"settings": [
{ "installation_title": "Digital Collections" },
{ "$import": "./shared/settings.json" }
]
}
Blueprints may contain // and /* */ comments and trailing commas (jsonc). The $schema key
gives editors that understand JSON Schema completion and inline validation. Every key is optional.
A few things the specification leaves to the tool:
- A module given only by name gets the state
activate(install and enable).installinstalls it without enabling it;downloadonly puts the files inmodules/. - Without a
source, a module or theme is looked up by name, asmodule:download <name>andtheme:download <name>do. Itssourceis a release ZIP or a git repository:- a git repository is
gh:owner/repo,git@host:path.git, anhttp(s)://URL that ends in.git, orhttps://github.com/owner/repo, each with an optional#<branch, tag or commit>; - a ZIP is any other
http(s)://URL, a local ZIP (relative to the file that declares it), or a ZIP in a repository (gh:owner/repo@v1.0:dist/Module.zip).
- a git repository is
version picks the repository release, or the git ref when the source has no #ref; a ZIP pins the
release itself. The name and the version are their own keys: CleanUrl:3.4 is not a source.
- A module or theme that is already in modules/ or themes/ is used as it is, unless version
differs from the one on disk or you deploy with --update.
- A user without password cannot log in until a password is set (for example with Forgot
password). role defaults to author.
- A site is identified by its slug, or by its title when it has none. Its theme must be listed in
themes; default ships with Omeka S and always counts.
- settings is a map of global settings, or a list of maps and $import references merged in order
(a later value wins).
- items and itemSets are created by the content phases, see Content. meta,
preferredVersions.php and top-level x- keys other than x-omeka-s-cli are accepted and ignored.
Check the blueprint before you deploy it:
Deploy from scratch¶
Point --base-path at an empty directory (or one that does not exist yet) and give the credentials of
an existing, empty database:
omeka-s-cli blueprint:deploy ~/blueprints/site.blueprint.jsonc \
--base-path /var/www/omeka-s \
--db-host db --db-name omeka --db-user omeka --db-password "$DB_PASSWORD" \
--admin-email admin@example.org --admin-password "$ADMIN_PASSWORD"
The deploy downloads Omeka S, writes config/database.ini, installs Omeka S, and then runs the other
phases. The database must exist and the user must be allowed to create tables in it: the deploy does
not create databases. See the core phase for the details.
Set the administrator
The administrator comes from --admin-name, --admin-email and --admin-password, else from
install.admin in the blueprint. Without either, it is admin@example.com with the password
admin. Always pass --admin-password from an environment variable or a secret store.
Phases and order¶
A deploy runs these phases, in this order, and reports each one:
| Phase | Blueprint key | What it does |
|---|---|---|
core |
install, preferredVersions.omeka |
download, configure and install Omeka S (core:*) |
modules |
modules |
module:download, then module:install or module:enable |
themes |
themes |
theme:download |
files |
files |
copy (or unzip) files into the Omeka S directory |
vocabularies |
vocabularies |
vocabulary:import |
resourceTemplates |
resourceTemplates |
resource-template:import (needs the Common module) |
users |
users |
user:add |
sites |
sites |
site:add, site:update (with --update), site:set-permission |
itemSets |
itemSets, x-omeka-s-cli.itemSets |
item-set:import |
items |
items, x-omeka-s-cli.items |
item:import, with the item's media |
settings |
settings |
config:set |
Vocabularies come before resource templates, so the properties a template uses exist. Users come
before sites, because a site permission names a user. Item sets and items come after sites, so an
item can be added to a site, and item sets come before the items that belong to them. Settings come last, so a module that writes its
defaults when it is installed cannot overwrite them. files destinations are relative to the Omeka S
directory (no absolute paths, no ..), so a file can land inside a module that was just downloaded.
A module's services are only available in a process that starts with the module already active. The
deploy therefore installs every module in a new process of its own, in the order of the blueprint,
and runs the phases from vocabularies on in one more process. List a module after the modules it
depends on (Common first); if the order is wrong, Omeka S reports the missing dependency and the
deploy stops.
--skip leaves out phases, --dry-run lists the actions without performing them. See
the commands page.
Content¶
A blueprint can seed an instance with item sets and items, for a demo or a test instance. There are two ways to write them, and a blueprint can mix both:
- The shared format's
itemSetsanditems: a few fields written in the blueprint.title,descriptionandcreatorbecome Dublin Core values; an item names its item sets by title and itssitesby slug (or title). A mediaurlthat is anhttp(s)URL is downloaded by Omeka S; a relative path is a file next to the blueprint. - The CLI's own entries, under
x-omeka-s-cli: either one portable JSON-LD file per item set or item (source), asitem:exportwrites it, or only atitle, which becomes thedcterms:title. Any other property belongs in a JSON-LD file. A title-only item also takes itsitemSets(by title); every item takessitesand any number ofmedia. A media takes the same object asmedia:add --data: aningester, asource, and whatever else the ingester takes (the shared format usestypeandurlinstead). With asource, the entry'stitleis only used in messages.
An item's sites are slugs or titles, matched without case. When none of them matches a site, the
item goes to the default site, and so does a shared-format or title-only item without sites. An item
from a JSON-LD file keeps the file's o:site unless the entry gives sites. Without a default site
(or for a file without o:site), Omeka S adds the item to every site that takes new items; site:add
switches that on unless you pass --no-assign-new-items.
content.blueprint.jsonc
{
"$schema": "https://omeka-s-contrib.github.io/omeka-s-blueprints/schema/v0/blueprint-schema.json",
"meta": { "title": "Content", "description": "Item sets and items, in both notations." },
// the shared format: a few fields, written in the blueprint
"itemSets": [ { "title": "Postcards", "description": "Postcards of the town" } ],
"items": [
{ "title": "Market square", "creator": "Anonymous", "itemSets": ["Postcards"], "sites": ["collections"],
"media": [ { "url": "./content/media/market.png", "title": "Front" } ] }
],
// the CLI's own entries: a portable JSON-LD file per resource, or only a title
"x-omeka-s-cli": {
"itemSets": [ { "source": "./content/item-sets/photographs.jsonld", "title": "Photographs" } ],
"items": [
{ "source": "./content/items/harbour.jsonld", "title": "Harbour at dawn",
"media": [
{ "ingester": "upload", "source": "./content/media/harbour.png", "altText": "A harbour at dawn" },
{ "ingester": "html", "source": "<p>Glass plate negative.</p>" }
] },
{ "title": "Street at night", "itemSets": ["Photographs"],
"media": [ { "ingester": "upload", "source": "./content/media/street.png" } ] }
]
}
}
The simple entries come first, then the x-omeka-s-cli entries, each in blueprint order. An item is
created together with its media: if Omeka S rejects a media file, the item is not created either. An
item or item set that already exists (by its o-ref:id, else by its title) is skipped, so a deploy can
run again. A simple item names its item sets by title, and the item set is found by the title in its
JSON-LD file, or in the instance. Validation only sees the blueprint, so it warns about an item set
that the blueprint does not declare; when a simple item names an x-omeka-s-cli item set, give that
entry a title equal to the title in its file.
To build the JSON-LD files, curate the content on an instance and export it, one file per item:
omeka-s-cli item:export --property dcterms:identifier=ph-1 --reference-by dcterms:identifier \
--output-dir ~/content/items
Then list the files as x-omeka-s-cli.items entries, and add the media.
When an entry fails¶
An item set or item that cannot be created stops the deploy. These are the errors:
- a missing vocabulary, or an unknown property, class, resource template or data type;
- a media file that cannot be fetched, or that Omeka S rejects;
- a reference that matches no record or more than one: an
o-ref:refin a JSON-LD file, or an item set that an item names by title.
Content that a deploy can do without, such as sample content on a demo instance, can say
"onError": "skip": the deploy leaves it out with a warning, carries on, and lists the skipped entries
at the end. The exit code is still 0. "onError": "fail" is the default.
content-skip.blueprint.jsonc
{
"$schema": "https://omeka-s-contrib.github.io/omeka-s-blueprints/schema/v0/blueprint-schema.json",
"meta": { "title": "Demo content", "description": "Required content, and sample content that may be left out." },
"x-omeka-s-cli": {
"itemSets": [ { "title": "Letters" } ],
"items": [
// required: the deploy stops if it cannot be created
{ "title": "Letter to the mayor", "itemSets": ["Letters"] },
// sample content: left out with a warning if it cannot be created
{ "source": "./content/items/sketch.jsonld", "title": "Harbour sketch", "onError": "skip" }
]
}
}
Items
Item 'Letter to the mayor' created (id 11).
skipped item 'Harbour sketch': link "o:item_set" to item sets with dcterms:identifier = "set-sketches" not found
Settings — nothing to do
Skipped 1 entry (onError: skip):
- item 'Harbour sketch': link "o:item_set" to item sets with dcterms:identifier = "set-sketches" not found
Blueprint deployed.
A skipped entry is not created, so an entry that refers to it fails in turn, and its own onError
decides what happens. For the same reason, a reference must point to an entry listed earlier or to a
record already in the instance: of two items that link to each other, keep the link only in the one
listed later. A record that already exists is not an error, even when its file no longer applies
cleanly, so a blueprint can be deployed again. The shared format's itemSets and
items take onError too, from the next release of the blueprint schema; until then, validation
accepts it only on x-omeka-s-cli entries.
Re-run a deploy¶
A deploy can be repeated: what already exists is left alone. To apply a blueprint to an installed
instance without reinstalling it, skip the core phase and confirm with --force:
omeka-s-cli blueprint:deploy ~/blueprints/site.blueprint.jsonc --base-path /var/www/omeka-s --skip core --force
Modules and themes on disk, existing vocabularies, resource templates, users and sites, and existing
permissions are skipped with a note. Settings and files are written every time. With --update, the
deploy also replaces modules, themes, vocabularies and resource templates, and updates sites and
permission roles. Users and permissions are never removed: a blueprint adds and updates, it does not
delete. See Deploy again.
The core phase¶
The core phase runs whenever you do not skip it, and needs --base-path. It:
- downloads Omeka S into
--base-path, unless that directory already holds an Omeka S installation. The version ispreferredVersions.omekafrom the blueprint, else the latest release. - writes
config/database.inifrom the--db-*options, unless the file already holds credentials. - checks that the database is reachable. If Omeka S is already installed in it, the deploy stops,
unless you pass
--force: then it drops all tables of the database. - installs Omeka S with the
title,localeandtimezonefrom the blueprint'sinstall(defaultsOmeka S,en_US,UTC) and the administrator from the--admin-*options orinstall.admin.
So --force without --skip core resets an instance and deploys the blueprint on a clean database:
omeka-s-cli blueprint:deploy ~/blueprints/site.blueprint.jsonc --base-path /var/www/omeka-s --force \
--admin-password "$ADMIN_PASSWORD"
A reset deletes all content
Items, media, sites, users and settings are gone after a reset. Back up the database first.
A reset keeps the existing database.ini, so the --db-* options are not needed (and are ignored).
The files in modules/ and themes/ stay; the module and theme phases install them again. Pass
--admin-password again: without it, the new administrator gets the password from
install.admin.password, else admin.
Share lists between blueprints¶
Any list in a blueprint (modules, themes, files, vocabularies, resourceTemplates, users,
sites, and the settings list) may contain { "$import": "<file or URL>" }. The entry is replaced by
the entries of the referenced list, in place. The site blueprint above imports this module list:
// The modules every site gets. Common comes first: other modules depend on it.
[
{ "name": "Common", "state": "activate" },
{ "name": "Sharing", "state": "activate" }
]
and this settings file:
A shared list can be validated on its own with --as:
omeka-s-cli blueprint:validate ~/blueprints/shared/modules.jsonc --as modules
omeka-s-cli blueprint:validate ~/blueprints/shared/settings.json --as settings
References are resolved relative to the file that contains them, may be nested, and may not be
circular. An entry that appears twice in a list (the same module or theme name, file destination,
vocabulary namespaceUri, resource template label, user email, site slug) is merged into the
first one: the fields of the later entry replace those of the earlier one, and the entry keeps its
first position. That lets a blueprint import a shared list and change one field, without changing the
module order:
{
"$schema": "https://omeka-s-contrib.github.io/omeka-s-blueprints/schema/v0/blueprint-schema.json",
"modules": [
// the shared list lives outside this directory: validate and deploy with --root
{ "$import": "../shared/modules.jsonc" },
// layering: keep Sharing in its place, but only download it
{ "name": "Sharing", "state": "download" }
],
"sites": [
{ "title": "Library", "slug": "library" }
]
}
Here Sharing stays second in the list, with the state download. The merge is shallow: a field
given again (a site's permissions, for example) is replaced as a whole. When a merge changes a
value, blueprint:validate and blueprint:deploy print a warning, so an accidental duplicate does
not go unnoticed.
Reference forms¶
The blueprint given on the command line, every $import, the source of files, vocabularies,
resourceTemplates, modules and themes, and a media url accept:
| Form | Example |
|---|---|
| Relative path | ./shared/modules.jsonc, ../shared/modules.jsonc |
| URL | https://example.org/blueprints/site.blueprint.jsonc |
| GitHub file URL | https://github.com/owner/repo/blob/main/site.blueprint.jsonc |
| GitHub short form | gh:owner/repo@main:site.blueprint.jsonc |
| GitLab file URL | https://gitlab.com/group/project/-/blob/main/site.blueprint.jsonc |
| GitLab short form | gl:group/project@main:site.blueprint.jsonc |
GitHub and GitLab file URLs are turned into raw download URLs; GitLab URLs are recognised by their
/-/blob/ segment, so self-hosted GitLab works too. In the short forms, @<branch, tag or commit> is
optional (default: HEAD); gl: always means gitlab.com. A blueprint fetched from a URL resolves its
relative references against that URL, so a blueprint in a repository can import its neighbours. Only
public files can be fetched. Only modules and themes take a git repository; other fields need a single
file. A URL with a user name and password in it (https://user:password@…) works, but the CLI prints
it as https://***@…; a token in the query string is printed as it is.
Relative paths¶
A relative path resolves against the file that declares it: the blueprint, or the file that imports
it. Write it with ./; a path without it works too, unless it starts like a URL scheme (notes: in
./notes:1.json). Relative paths are URL references, as in a web page:
%,#and?must be percent-encoded (notes%231.pdf); an unencoded#or?in a path to a local file is an error;My%20File.pdfnames the fileMy File.pdf; write spaces encoded: the specification release the CLI validates against (v0.1.0) rejects a raw space infiles,vocabulariesand mediaurl;\separates folders, like/.
A value that starts with whitespace, an absolute path (/etc/…, C:\…) and a URL scheme other than
http(s)://, gh:, gl: or git@host: (such as file:, php:// or ftp://) is rejected.
Local references stay inside the root¶
A blueprint must not be able to read any file on the server it is deployed on. A relative path must
stay inside the blueprint root: the directory of the blueprint given on the command line (or, for a
blueprint loaded from a URL, its folder URL). .. may go back up to the root, not beyond, also when it
is written %2e%2e or with \. A file imported by an absolute URL or by gh:/gl: has its own
folder as root; a file imported by a relative path keeps the root of the file that imports it. The
library blueprint above imports ../shared/modules.jsonc, outside its own directory, so it needs
--root:
--root works the same on blueprint:deploy. The path on the command line is not checked: it may be
absolute. --root takes a local directory only: a blueprint loaded from a URL or gh:/gl: keeps its
folder URL as root, and --root with it is an error. The same rules apply to the configuration files
of item:import, media:add and vocabulary:import, see
Refer to files.
Capture an existing instance¶
blueprint:export writes a blueprint from a running instance, to reproduce it elsewhere or to start
a blueprint from. It covers modules, themes, vocabularies and sites (and, on request, site permissions
with their users), not settings or resource templates yet. See
Export an instance.
Keep secrets out of the blueprint¶
The database password and the administrator password are command-line options, so the blueprint can
go into version control. install.admin.password and the password of a user are stored in the
blueprint in clear text: a blueprint that contains them is a secret itself. Leave them out, and set
the passwords with --admin-password and user:update-password (or let users
use Forgot password).
Bundle a blueprint for offline deploys¶
A deploy downloads the Omeka S core, modules, themes and vocabularies from omeka.org, GitHub and
other hosts, so it fails when one of them is down. blueprint:bundle downloads all of them once into
one directory, and writes a blueprint.json there that only refers to files in that directory:
bundle/
blueprint.json # every $import inlined, every version pinned
core/omeka-s-4.2.1.zip # x-omeka-s-cli.install.source
modules/Common-3.4.71.zip
themes/freedom-1.0.7.zip
vocabularies/coll.ttl
resource-templates/book.json
files/logo.png
item-sets/photographs.jsonld # x-omeka-s-cli.itemSets sources
items/harbour.jsonld # x-omeka-s-cli.items sources
media/harbour.png # upload media and relative simple media
The bundle pins what it downloaded:
preferredVersions.omeka(the latest release if the blueprint had none);- every module and theme version;
- the format of each vocabulary.
Modules and themes are bundled as their release ZIPs, unchanged. A git or gh: source can't be
bundled, because a checkout may need build steps before it can be installed: point its source to a
release ZIP (a URL or a path) instead. Add-ons are named after their folder: a module after its
namespace, a repository theme after its repository folder.
Media that are links (url media with an http(s) URL, iiif, youtube, html, ...) stay links:
a deploy from the bundle still needs the network for them. A media file without an extension gets
one from its Content-Type, because Omeka S checks the extension.
The blueprint format has no field for the Omeka S release yet, so the bundle stores it in the CLI's
own extension key, x-omeka-s-cli.install.source. Other tools ignore that key. You can set it in any
blueprint, to a release ZIP path or URL, and the core phase installs from it.
Deploy the bundle with --self-contained. It refuses a blueprint that still refers to anything
outside its directory: a repository name, a git repository, a URL, or a missing
x-omeka-s-cli.install.source.
A bundle can also live in a git repository or on a web server. Deployed from there, for example
gh:org/infra@v1:bundle/blueprint.json, it only downloads from that location.
Passwords in the blueprint (install.admin.password, user passwords) are copied into the bundle
unchanged. Keep them out of the blueprint and pass them at deploy time instead; see
Keep secrets out of the blueprint.
In a Docker image¶
There are two ways to use a blueprint in an image.
Ship the code in the image. Download the core, modules and themes in a build stage with
blueprint:download. Every container then
runs the same code, and needs no network to start: only a database and a volume for files/.
Rebuild the image when the blueprint changes.
# Build stage: has network access, and puts the Omeka S core, modules, themes and files in place.
FROM php:8.2-cli AS download
RUN apt-get update && apt-get install -y --no-install-recommends git unzip libzip-dev \
&& docker-php-ext-install zip && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ADD --chmod=755 https://github.com/GhentCDH/Omeka-S-Cli/releases/latest/download/omeka-s-cli.phar /usr/local/bin/omeka-s-cli
# the blueprint and the files it refers to
COPY . /src/
RUN omeka-s-cli blueprint:download /src/site.blueprint.jsonc --base-path /var/www/omeka-s
# Runtime image (your PHP + web server image): ships the code. A container only needs a database
# (config/database.ini) and a volume for the uploaded files.
FROM your-omeka-runtime-image
COPY --from=download /usr/local/bin/omeka-s-cli /usr/local/bin/omeka-s-cli
COPY --from=download /var/www/omeka-s /var/www/omeka-s
VOLUME /var/www/omeka-s/files
The image has no database yet. When a container starts, write config/database.ini
(config:create-db-ini), and install
Omeka S and the modules on an empty database, for example with core:install followed by
blueprint:deploy --skip core --force. A file in the blueprint with a destination under files/ is
hidden by the volume: put such files on the volume instead.
Deploy a bundle at the first start. Bundle in a build stage, which has network access. Deploy
when the container starts, once the database is reachable. Only the first start deploys: keep /var/www/omeka-s on a volume, and a
later start finds Omeka S installed and only starts the web server.
# Build stage: has network access, and downloads everything the blueprint needs.
FROM php:8.2-cli AS bundle
RUN apt-get update && apt-get install -y --no-install-recommends git unzip libzip-dev \
&& docker-php-ext-install zip && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
ADD --chmod=755 https://github.com/GhentCDH/Omeka-S-Cli/releases/latest/download/omeka-s-cli.phar /usr/local/bin/omeka-s-cli
COPY site.blueprint.jsonc /src/
RUN omeka-s-cli blueprint:bundle /src/site.blueprint.jsonc /opt/bundle
# Runtime image (your PHP + web server image): deploys the bundle on the first start, with no
# downloads from omeka.org, GitHub or vocabulary hosts. Keep /var/www/omeka-s on a volume: a later
# start finds Omeka S installed and only starts the web server.
FROM your-omeka-runtime-image
COPY --from=bundle /usr/local/bin/omeka-s-cli /usr/local/bin/omeka-s-cli
COPY --from=bundle /opt/bundle /opt/bundle
CMD omeka-s-cli core:status --is-installed --base-path /var/www/omeka-s || \
omeka-s-cli blueprint:deploy /opt/bundle/blueprint.json --self-contained \
--base-path /var/www/omeka-s --db-host "$DB_HOST" --db-name "$DB_NAME" \
--db-user "$DB_USER" --db-password "$DB_PASSWORD" --admin-password "$ADMIN_PASSWORD" \
&& exec apache2-foreground
Omeka S Playground¶
The format started as the blueprint of the Omeka S Playground,
and a Playground blueprint deploys with omeka-s-cli as it is. Keys that only one tool understands live
under a top-level x- key (x-playground for the Playground's landing page and login, for example);
omeka-s-cli ignores them. Compared with the original Playground format, the specification adds
vocabularies, resourceTemplates, settings, files, module and theme version, the module state
download, and $import.