Skip to content
landfall

Deploy to a group

A group deploy puts one release on every server of the group. The group is servers in .landfall.json. See Several servers.

# deploy to every server in .landfall.json's servers
lf deploy
# or name the servers; .landfall.json then keeps them as its servers
lf deploy -s vps1,vps2

What happens, in order:

  1. landfall checks that every server is set up, and locks the site on each of them.
  2. It uploads the files and prepares the release on the primary, and checks it there: the compose file, pins, volumes, domains, certificates. Only then does it upload to the other servers. The release id is the same on all of them.
  3. It builds once: on your machine with --build-local, else on the primary. The images go from there to the other servers (docker save, docker load over ssh). The servers must share one platform, like linux/amd64. The primary pulls the other images. The release keeps the digest of each one. The other servers pull those digests, so a tag like latest cannot move in between. A rollback and lf sync use the same digests. No server switches before every server has the images.
  4. It switches one server at a time, the primary first. Each one passes its health check before the next one starts.
  5. When every server runs the release, the postdeploy hook runs once, on the primary.
diagramdiagram
  • The release hook (migrations) runs once, on the primary, before its switch.
  • verify runs on each server.
  • "on": "all" runs release or postdeploy on every server. See Hooks: On a group of servers.
  • If a server fails, the servers that already switched go back to the release they ran. The group never stays half deployed. onfailure gets LANDFALL_FAILED_SERVER, the server that failed.
  • Hooks get LANDFALL_SERVERS, the group's servers as vps1,vps2.
  • Values that lf deploy asks for (a missing env variable) are asked once and go to every server.
  • The output ends with the run id. lf undo <run id> reverts the whole deploy on every server.
  • The servers' clocks should agree. landfall warns when they differ by more than a minute.
  • lf ci init gives the CI job a login on every server of the group. See Git deploys.

What a group deploy refuses

Each server keeps its own volumes. A site whose data lives on the server would get a different copy on each one. So a group deploy refuses:

  • a named volume, unless you mark it as fine to start empty on each server, or its service runs on the primary only;
  • a writable bind mount outside the release folder, like /srv/uploads.

lf volume add in a group's folder says so too. For an app, it refuses without --local.

Keep the data outside the servers (a database server, object storage). A volume that only holds a cache can stay, marked local: each server keeps its own copy, starting empty.

lf volume add /app/cache --local        # an app: lists app-cache in localVolumes
lf volume add web:/cache --local        # compose.yaml: marks the volume as below

For an app, --local also marks a volume that .landfall.json already lists.

volumes:
  cache:
    x-landfall:
      local: true

A group deploy also refuses domains that get certificates by HTTP challenge. See Certificates.

--git and --host work on one server only. Pick it with -s <server> and --partial.

Run a service on the primary only

A database can stay on one server of the group: pin it to the primary. Its volume then lives on the primary, and the group deploy accepts it.

services:
  db:
    image: postgres:17
    volumes: [pg:/var/lib/postgresql/data]
    x-landfall:
      server: primary
      expose: [5432]
  • server is primary, or the primary's name. The primary is the first of servers.
  • expose lists the ports the other servers reach it on. Without it, compose's expose: counts.
  • The primary publishes these ports on its private address only. Set it with lf server config <primary> --private-ip <ip>.
  • On the other servers the service runs no container. Services on its network reach it by its name, as on the primary.
  • It runs once: no deploy.replicas, lf scale or autoscale above 1. It cannot be routed.
  • lf tunnel and lf volume reach it on the primary.
  • Its volumes stay on the server it ran on. A deploy with another primary asks first: the service starts there without its data. Without a terminal it refuses, and -y does not answer it.
  • lf sites info lists it under its server.
  • Only the private network should reach these ports. Keep them closed in your cloud firewall.

Deploy to part of a group

A deploy to the group needs every server. If one does not answer, nothing is deployed.

# deploy to the servers that answer; the others keep their release
lf deploy --partial
# deploy to vps2 only
lf deploy -s vps2 --partial
  • Without --partial, both are refused. The servers would differ.
  • --partial warns which servers it deploys to, and which one is the primary.
  • .landfall.json keeps the whole group as its servers.
  • The group drifts. lf sync brings it back.
  • Without .landfall.json, lf deploy -s vps2 deploys to vps2 and takes it out of the group. landfall warns first. --partial keeps it in.

When the primary does not answer, --partial makes the next server the primary for this deploy. lf sync copies from the first server it is given. It refuses to take a newer release back to the primary's older one, and names the order to use.

# deploy while vps1 is down: vps2 becomes the primary
lf deploy --partial
# once vps1 is back: copy vps2's release to vps1
lf sync -s vps2,vps1

Certificates

With the default HTTP challenge, Let's Encrypt asks the server DNS points at. The other servers never get a certificate. A group deploy refuses that. An edge holds the certificates for the whole group. Without an edge, pick one of these on every server of the group:

# each server gets its certificates through your DNS provider's API
printf %s "$CF_TOKEN" | lf traefik dns cloudflare --token-stdin -s vps1
printf %s "$CF_TOKEN" | lf traefik dns cloudflare --token-stdin -s vps2
# or: a load balancer ends TLS and sends HTTP to the servers
lf traefik behind 10.0.0.0/16 -s vps1
lf traefik behind 10.0.0.0/16 -s vps2
  • With a load balancer that ends TLS, mark the services tls: lb in x-landfall (Compose sites). Behind a load balancer, a routed service without tls: lb still gets its own certificate, so the deploy refuses it too.
  • lf sites info shows the group's tls: dns or lb when every server uses it, else http.
  • See Traefik: Certificates.