Service or embedded
On Postgres, moving from embedded to service mode is a dump and restore of
the
latchkey schema, then switching the product’s LATCHKEY_MODE to
remote. Embedded SQLite keeps its data in latchkey.db, which has no
schema to dump, so latchkey export copies it into the service’s Postgres.
1
Stop the product
The export reads
latchkey.db as the product left it, so nothing may
write to it.2
Prepare the database
Run
install.sql and migrate with the same Latchkey version the product
embeds. The export refuses a database at another migration, or one that
already holds a policy. A service may already run against it, with the
owners it wrote from LATCHKEY_DOMAINS, which the export keeps. Start it
without LATCHKEY_BOOTSTRAP_TENANT, since a tenant it creates makes the
export refuse.3
Export
Connect as It copies every domain, kind, tenant, subject, role, group, binding and
audit entry in one transaction, with their revisions and timestamps. A
running service picks it up by its next poll, which runs every 5 seconds.
latchkey_app, with the password in PGPASSWORD rather than
the command line.4
Switch the product
Start the service, then set the product’s
LATCHKEY_MODE to remote
with LATCHKEY_ADDR pointing at it, and start the product.Server image
Each release publishes the server asghcr.io/galaxy-io/latchkey/server,
tagged with the version, such as 0.1.0, with latest and with the commit,
such as sha-1a2b3c4, for amd64 and arm64. The image holds one static
binary with the admin UI embedded and listens on port 8080. It runs as user 65532, not root, so a
volume for a SQLite database must be writable by that user. Run it with
-migrate to apply migrations and exit.
GET /version on the server answers with its version, commit and build
date, without a token.
Kubernetes
Each release also publishes a Helm chart for service mode.latchkey_owner and the server as
latchkey_app, so the Secret holds both connection strings, as
postgres-owner-dsn and postgres-dsn. Only the Job reads the owner one.
Run install.sql once before the first install. The chart’s README lists
every value.
Galaxy Cloud
- Each tenant namespace runs one instance in service mode. It has two
replicas with a PodDisruptionBudget of
maxUnavailable: 1, and its database lives on the tenant’s existing RDS. Filament and Alchemy call the instance in their own namespace. - The edge validates the session and calls the Management Service’s
ResolveCallerfor the caller and tenant. It forwards the request with a caller assertion it signs for the target service, and Latchkey verifies that assertion the same way products do. The edge never calls Latchkey. - Network policy lets only the tenant’s product pods and the Management Service reach the instance.
- Management puts the tenant id and the tenant creator’s platform id in the
deployment intent. Latchkey reads them from
LATCHKEY_BOOTSTRAP_TENANTandLATCHKEY_BOOTSTRAP_ADMIN, and on first boot provisions the tenant and binds the creator to Admin. No provisioning step waits for Latchkey to come up. - Identity, tenants and provisioning are specified in the Management Service proposal. Latchkey replaces that proposal’s Permissions section, so Management stores no roles or grants and its Caller carries no grants.
- Galaxy Cloud sets resource requests for each instance, and a fleet upgrade rolls tenant by tenant. Migrations stay compatible with the previous release, so tenants can run mixed versions during the rollout.
Where identities come from
In V1, users and groups arrive through directory sync from the tenant’s directory owner, which callsDirectoryService. In Galaxy Cloud that owner is
the Management Service, which takes SCIM from the IdP itself. A user can also
be created just in time the first time it is checked, and Admins can add
subjects by IdP id.
After V1, standalone installs get a SCIM 2.0 endpoint at /scim/v2/Users and
/scim/v2/Groups on the same HTTP server. It is plain REST, not Connect, and
it authenticates with its own bearer token, in embedded mode too.
Database boundary
In both modes the Latchkey tables live in their ownlatchkey schema behind
their own Postgres roles, so product code cannot read or write them. The only
crossing is latchkey.purge_resource().
- Create the schema and roles once with
datastore/postgres/install.sql. - Migrations are goose files under
datastore/postgres/migrations. The server applies them with-migrateand exits, run as a separate step such as a Helm pre-upgrade hook with owner credentials. A Postgres advisory lock keeps two runners from racing. - The runtime connects as
latchkey_app. It refuses to start if the schema is behind the version it expects. A newer schema is fine, since every migration stays compatible with the previous release. - Every migration stays compatible with the previous release. Expand now and
contract one release later, so old replicas keep running during an upgrade
and
helm rollbackworks. Never edit a shipped migration. Append a new numbered file. - Simple installs such as Docker Compose can migrate at startup by giving the process owner credentials.
- Embedded installs follow the host’s migration step. The library exposes
postgres.Migrate(ctx, ownerDB). Filament runs its Postgres migrations from a Helm post-upgrade job and calls it from there, never at boot.
SQLite
Filament’s standalone mode runs everything in one process over SQLite, so embedded mode ships a SQLite store too.- The Latchkey data lives in its own file,
latchkey.db, next to the product’s. SQLite has no schemas or roles, so the boundary is the separate file and the package API. - Cleanup cannot share the delete’s transaction, because commits across two
SQLite files in WAL mode are not atomic. The interceptor purges after the
delete commits. A periodic sweep that removes bindings whose resource no
longer exists, for products that implement
ListResources, is planned. Filament soft deletes rows and uses UUIDs, so a leftover binding never grants anything. - Migrations are goose files under
datastore/sqlite/migrations. The product callsMigrateat startup, since it owns the file. The audit log refuses updates, and with no partitions, pruning deletes rows older than the retention.