Skip to content

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.

<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.

  1. 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.
  2. Set an explicit container_name on every service, normally the service name (shop-prod). It is what you type in moira update shop-prod, and it must be unique per host. Duplicates across hosts are fine; the client resolves them.
  3. Put env in env_files next to the compose file, named <something>.env, mode 600. Avoid environment: for secrets. Only *.env files referenced as env_file can be edited through moira.
  4. Use relative paths for bind mounts and env files (./data, prod.env). Compose resolves them against the stack directory, and moirad mounts the deploy folder at the same path, so they behave the same from SSH and from moira.
  5. Put shared infrastructure on external networks (infra). Create them once with docker network create, outside any stack.
  6. The image tag decides what ships: for example :stable for prod and :latest for staging. moira update pulls the tag in the compose file. Changing the tag is a compose edit followed by apply.
  7. No git in the deploy folder. Env history is .history/, written by moirad. Hand-made *.bak-<tag> copies are fine and show up as history entries.
  8. One-shot services (migrations) should use restart: "no" so their exited state isn’t mistaken for a failure. Hide them with moira hide.
  9. Avoid containers outside the deploy folder. Bare docker run containers show up as unmanaged and only get logs, restart, start and stop.
  10. Registry logins inline in /root/.docker/config.json, with no credential helper, so moirad can pull.

moirad never edits compose files and never creates or deletes stacks. It writes only:

  • its state directory (<DEPLOY_DIR>/moirad/ by default);
  • *.env files you save through moira;
  • <stack>/.history/ backups of those files (mode 0600, directory 0700, owned by the daemon’s user).
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