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,vps2What happens, in order:
- landfall checks that every server is set up, and locks the site on each of them.
- 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.
- 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 loadover ssh). The servers must share one platform, likelinux/amd64. The primary pulls the other images. The release keeps the digest of each one. The other servers pull those digests, so a tag likelatestcannot move in between. A rollback andlf syncuse the same digests. No server switches before every server has the images. - It switches one server at a time, the primary first. Each one passes its health check before the next one starts.
- When every server runs the release, the
postdeployhook runs once, on the primary.
- The
releasehook (migrations) runs once, on the primary, before its switch. verifyruns on each server."on": "all"runsreleaseorpostdeployon 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.
onfailuregetsLANDFALL_FAILED_SERVER, the server that failed. - Hooks get
LANDFALL_SERVERS, the group's servers asvps1,vps2. - Values that
lf deployasks 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 initgives 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 belowFor an app, --local also marks a volume that .landfall.json already lists.
volumes:
cache:
x-landfall:
local: trueA 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]serverisprimary, or the primary's name. The primary is the first ofservers.exposelists the ports the other servers reach it on. Without it, compose'sexpose: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 scaleor autoscale above 1. It cannot be routed. lf tunnelandlf volumereach 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
-ydoes not answer it. lf sites infolists 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. --partialwarns which servers it deploys to, and which one is the primary..landfall.jsonkeeps the whole group as its servers.- The group drifts.
lf syncbrings it back. - Without
.landfall.json,lf deploy -s vps2deploys to vps2 and takes it out of the group. landfall warns first.--partialkeeps 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,vps1Certificates
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: lbinx-landfall(Compose sites). Behind a load balancer, a routed service withouttls: lbstill gets its own certificate, so the deploy refuses it too. lf sites infoshows the group'stls:dnsorlbwhen every server uses it, elsehttp.- See Traefik: Certificates.