Deploy folder
moirad works with a deploy folder laid out one stack per directory. These rules are for the
people and agents who create and edit stacks over SSH.
Layout
Section titled “Layout”<DEPLOY_DIR>/ README.md host overview: what runs here, addresses, procedures <stack>/ compose.yml the stack; `name: <stack>` at the top prod.env staging.env env_file(s), mode 600, comments allowed RUNBOOK.md (optional) shown on the stack page in moira ui data/ postgres-data/ … (optional) bind-mounted data, relative paths .history/ written by moirad: env backups moirad/ moirad's own stack and state (tls/, clients.json)A stack is any direct subdirectory with a default Compose file: compose.yaml,
compose.yml, docker-compose.yml or docker-compose.yaml, in that order. Override files and
COMPOSE_FILE in the stack’s .env work as they do with plain Compose. Symlinked stack
directories are skipped.
- One stack per directory. The directory name equals the compose top-level
name:and is lowercase[a-z0-9._-]. A mismatch shows up as a warning. - Set an explicit
container_nameon every service, normally the service name (shop-prod). It is what you type inmoira update shop-prod, and it must be unique per host. Duplicates across hosts are fine; the client resolves them. - Put env in
env_files next to the compose file, named<something>.env, mode600. Avoidenvironment:for secrets. Only*.envfiles referenced asenv_filecan be edited through moira. - Use relative paths for bind mounts and env files (
./data,prod.env). Compose resolves them against the stack directory, andmoiradmounts the deploy folder at the same path, so they behave the same from SSH and from moira. - Put shared infrastructure on external networks (
infra). Create them once withdocker network create, outside any stack. - The image tag decides what ships: for example
:stablefor prod and:latestfor staging.moira updatepulls the tag in the compose file. Changing the tag is a compose edit followed byapply. - No git in the deploy folder. Env history is
.history/, written bymoirad. Hand-made*.bak-<tag>copies are fine and show up as history entries. - One-shot services (migrations) should use
restart: "no"so their exited state isn’t mistaken for a failure. Hide them withmoira hide. - Avoid containers outside the deploy folder. Bare
docker runcontainers show up as unmanaged and only get logs, restart, start and stop. - Registry logins inline in
/root/.docker/config.json, with no credential helper, somoiradcan pull.
What moirad writes
Section titled “What moirad writes”moirad never edits compose files and never creates or deletes stacks. It writes only:
- its state directory (
<DEPLOY_DIR>/moirad/by default); *.envfiles you save through moira;<stack>/.history/backups of those files (mode0600, directory0700, owned by the daemon’s user).
Example
Section titled “Example”name: shop
services: shop-prod: image: ghcr.io/example/shop:stable container_name: shop-prod restart: unless-stopped networks: [infra] env_file: prod.env volumes: - ./uploads:/app/uploads
shop-staging: image: ghcr.io/example/shop:latest container_name: shop-staging restart: unless-stopped networks: [infra] env_file: staging.env
networks: infra: external: true