2.5 KiB
Managed site secrets for Docker Compose
Create a canonical private directory owned by the trusted provisioning account
with mode 0700, outside all application source trees. Use a
SiteSecrets(config, directory, consumers) instance for the site and pass it
as site_secrets to ServiceLifecycle or ContainedServiceLifecycle.
The consumer mapping specifies Compose service names and their non-root
numeric UIDs. The provisioning process needs authority to assign those file
owners. The Compose project, base file and Docker daemon must be trusted.
Services must run without Docker access, privileged mode or extra host mounts
that bypass the per-site directory boundary.
Call rotate(service, filename, data) with the complete client credential file
as bytes from the trusted provisioning source. Supported filenames are
absdev-client.cnf and absdev-pgpass. Bind the matching service to the
database adapter's configured client container when using that adapter.
Credential bytes are stored in owner-only files. The Compose override contains
paths only and mounts each service's directory read-only at /run/secrets.
Keep that mount target reserved in the base Compose file. Unlisted services
receive no managed mount.
The containing directory stays mounted when the provisioner atomically replaces a file. New reads observe the replacement. Use server-side password rotation and reconnect clients for new authentication. Existing connections and programs that cache credentials require their own cutover. This runtime accepts credential material from a trusted caller and does not operate a production secret backend. Production execution remains disabled.
Local file backend
A trusted provisioner can use FileSecretBackend(directory, site, group)
and call backend.deliver(site_secrets, service, filename) to refresh the
runtime credential from the selected site. Place the store under
administrator-controlled ancestors. The root directory is root-owned mode
0711. Each site directory is root-owned mode 0750 with a dedicated site
group. Credential files are root-owned mode 0440 with that same group. Use
distinct groups for sites and grant each site identity only its own group.
The privileged provisioner is trusted across sites. Keep backend files out
of containers and use the read-only runtime mounts for delivery.
Publish replacements atomically in the backend, then trigger a fresh delivery for the site. A failed backend read leaves the current delivery unchanged. Any server-side update and client reconnect are managed by the caller. Production execution remains disabled.