Skip to content
landfall

Try it locally

You can try landfall without renting a server. A Docker container on your machine plays the server. It runs Ubuntu with systemd, sshd, ufw and its own Docker, like a fresh VPS. landfall cannot tell the difference: setup, deploys, rollbacks, undo, groups, edges, tenants and the web UI all work.

You need Docker and Node 22.4 or newer. The first part takes about five minutes.

partwhat you do
Steps 1 to 5start one test server, set it up, deploy a site, look around
Several serversone site on two servers, with a third one in front that balances them
Tenantsgive another person their own Docker on the test server
Clean upremove every test server

1. Get lf and the helpers

# the published CLI
npm i -g landfall
 
# everything this page creates lives in ~/landfall-try
mkdir -p ~/landfall-try && cd ~/landfall-try
 
# a few shell helpers for test servers; read it first, it is short
curl -fsSLO https://raw.githubusercontent.com/ph1p/landfall/main/test/e2e/ubuntu/try.sh
 
# load them into this shell
. ./try.sh

Loading try.sh does three things:

  • It points lf at ~/landfall-try for this shell. Your real servers in ~/.config/landfall and ~/.ssh/config stay untouched.
  • It creates the key ~/landfall-try/key, which only the test servers accept.
  • It defines these commands:
commandwhat it does
try_up <name> <ssh port> <https port>starts a test server, the container landfall-try-<name>. The first time, it builds the image.
try_cert <name>gives the server's Traefik a self-signed certificate for *.localhost
try_ip <name>prints the server's address on Docker's network
try_files <name>copies the server's /opt/landfall to ~/landfall-try/files/<name>
try_downremoves every test server

In a new shell, run cd ~/landfall-try && . ./try.sh again.

Check:

# prints the installed version
lf --version

2. Start a test server

# the test server "demo": ssh on port 2201, HTTPS on port 8443
try_up demo 2201 8443

The first run builds the image landfall-try. That takes a few minutes. try_up ends with ready and prints the setup command for the next step.

The ports listen on your machine only.

diagramdiagram

3. Set up the server

# set it up: deploy user, ufw, Docker check, Traefik, ssh alias "demo"
lf setup demo --host 127.0.0.1 --port 2201 --key ~/landfall-try/key --email you@example.com --staging -y
 
# Let's Encrypt cannot reach a container on your machine: a self-signed certificate instead
try_cert demo
  • --staging uses Let's Encrypt's test service.
  • Names under .localhost always point at your own machine. No DNS is involved.
  • The security notes at the end of setup (loose kernel settings, waiting updates) are expected here.
  • Setup creates the user deploy. From now on, landfall logs in as deploy, as on a real server.

Check:

# the server, its OS, Docker and Traefik
lf server info demo

4. Deploy a site

# a static site: a folder with an index.html
mkdir -p ~/landfall-try/hello && cd ~/landfall-try/hello
echo '<h1>hello from landfall</h1>' > index.html
 
# deploy it to the test server
lf deploy -s demo -d hello.localhost -y

deploy ends with a warning that it could not reach https://hello.localhost. It checks port 443, but the test server listens on 8443. The site is fine.

Check:

# prints <h1>hello from landfall</h1>; -k because the certificate is self-signed
curl -k https://hello.localhost:8443

In a browser, open https://hello.localhost:8443 and accept the certificate warning.

The site remembers its domain. Deploy a second release:

# a new release; the old one stays for rollback
echo '<h1>version 2</h1>' > index.html && lf deploy -y

Right after a deploy, the site can answer 404 page not found for a few seconds. Traefik needs that long to notice the new container.

5. Look around

lf ls                       # sites on the server
lf sites info hello         # services, domains and every release
lf logs hello               # container logs
lf rollback hello -y        # back to the previous release
lf history                  # every change landfall made on the server
lf undo                     # take back the last one
lf ssh demo                 # a shell on the test server
lf ui                       # the web UI in your browser

Everything landfall keeps on the server is a plain file under /opt/landfall. Copy it to your machine and look:

# copy the server's files, then list them without the release contents
try_files demo && find ~/landfall-try/files/demo -maxdepth 4 -not -path '*/releases/*/*'
pathwhat
READMEwhat the folder is, for whoever logs in after you
journal.logevery change landfall made. lf history reads it, lf undo replays its undo commands
landfall.jsonthe server's landfall settings
traefik/Traefik's Compose project and config
sites/hello/releases/one folder per deploy, named by date and time
sites/hello/currenta symlink to the live release
sites/hello/site.jsonthe site's domains, services and release history

The copy does not follow later changes. Run try_files demo again for a fresh one. Editing the copy changes nothing on the server.

Any project deploys the same way: a Node app, a Dockerfile, a Compose file. See Deploy a site. Nothing can break: the server is a container you throw away.

Optional: several servers

One site can run on a group of servers, with an edge in front that balances them. You start three more test servers:

  • vps1 and vps2 form the group. Both run the site. vps1 is the primary.
  • edge1 is the edge. It holds the domain and sends each request to one of the two.

The test servers reach each other on Docker's network, as on a private network. You do not need lf network here.

diagramdiagram

Start the servers

# three more test servers
try_up vps1 2202 8444
try_up vps2 2203 8445
try_up edge1 2204 8446
 
# set up each one, as in step 3
lf setup vps1 --host 127.0.0.1 --port 2202 --key ~/landfall-try/key --email you@example.com --staging -y
lf setup vps2 --host 127.0.0.1 --port 2203 --key ~/landfall-try/key --email you@example.com --staging -y
lf setup edge1 --host 127.0.0.1 --port 2204 --key ~/landfall-try/key --email you@example.com --staging -y
 
# the edge ends HTTPS for the domain, so it needs the certificate
try_cert edge1
 
# vps1 and vps2 trust the edge: they take the visitor's address from its headers
lf traefik behind $(try_ip edge1) -s vps1 -y
lf traefik behind $(try_ip edge1) -s vps2 -y

Check:

# lists demo, vps1, vps2 and edge1
lf server ls

Deploy to the group

The site is whoami, a small server that answers with its container's name. That shows which server answered.

# a Compose project
mkdir -p ~/landfall-try/shop && cd ~/landfall-try/shop
cat > compose.yaml <<'EOF'
services:
  web:
    image: traefik/whoami
    x-landfall:
      port: 80
      tls: lb
      healthcheck: { path: / }
EOF
 
# the group: vps1 comes first, so it is the primary
echo '{"servers": ["vps1", "vps2"]}' > .landfall.json
 
# one release, on vps1 first, then on vps2
lf deploy -d shop.localhost -y
  • tls: lb means a load balancer in front ends HTTPS.
  • The edge checks the health check path on each server.
  • deploy warns that it could not reach https://shop.localhost. The edge is not in place yet.

Check:

# both servers run the same release; the state is "ok"
lf sites info

Put the edge in front

# edge1 holds shop.localhost and balances vps1 and vps2
lf edge add edge1 -y

edge add warns that shop.localhost has no DNS record. Names under .localhost need none.

Check:

# four requests through the edge: two container names, taking turns
for i in 1 2 3 4; do curl -sk https://shop.localhost:8446 | grep Hostname; done

If curl prints nothing, wait a few seconds. The edge needs them to load its new route.

Work with the group

Run these in ~/landfall-try/shop. .landfall.json names the group and the edge.

lf edge                       # each server's weight, state and health
lf edge shop vps2=off -y      # the edge sends nothing to vps2; curl shows one name
lf edge shop vps2=on -y       # vps2 takes requests again
lf scale shop web=3 -s vps1 -y  # three web containers on vps1 only
lf sites info                 # reports drift: vps2 runs one
lf sync -y                    # vps2 follows the primary
lf deploy -y                  # the edge takes each server out while it switches
lf history -s vps1            # a group deploy is one run on every server

See Deploy to a group, Sync and drift and An edge in front. In the web UI, the site shows as a group with an Edge card. See Groups in the web UI.

Optional: tenants

Tenants give other people their own rootless Docker on your server. The test server has everything they need (Requirements).

You play two people here:

  • you, the admin, with the server demo from step 3.
  • anna, the tenant. landfall creates the Linux user anna on demo. She logs in with her own key, ~/landfall-try/anna.
# anna's key pair: the public half goes to the admin, the private half is her login
ssh-keygen -q -t ed25519 -N "" -f ~/landfall-try/anna

Add the tenant with lf

# you: add anna with her key and domains
lf tenant add anna -s demo --key ~/landfall-try/anna.pub -d anna.localhost -d '*.anna.localhost' --force
 
# anna: register her login and start her Traefik
lf server add anna --host 127.0.0.1 --port 2201 --user anna -i ~/landfall-try/anna
lf traefik setup -s anna --email you@example.com --staging -y

The first tenant needs --force: it moves Traefik to the host network, which restarts it.

Or add the tenant in the web UI

Start lf ui from a shell that loaded try.sh. Otherwise, the UI writes to your real config.

  1. As you, open Tenants on demo and click Add tenant:

    fieldvalue
    Useranna
    Public keythe output of cat ~/landfall-try/anna.pub
    Domainsanna.localhost *.anna.localhost

    The first tenant restarts Traefik. The UI asks you to confirm. The invite it shows next is for a real tenant. Here, anna's key is ~/landfall-try/anna.

  2. As anna, click Add server:

    fieldvalue
    Nameanna
    Address127.0.0.1
    Useranna
    SSH port2201
    Private key file~/landfall-try/anna

    Uncheck Set it up now. A tenant cannot set up the server.

  3. Open Traefik on anna and click Install it. This starts anna's own Traefik.

Deploy as anna

# a self-signed certificate for anna's domains, in anna's Traefik
try_cert demo anna
 
# deploy the hello site as anna
cd ~/landfall-try/hello && lf deploy -s anna -d blog.anna.localhost -y

The central Traefik passes blog.anna.localhost to anna's Traefik, still encrypted.

Check:

# the hello page, served by anna's Traefik
curl -k https://blog.anna.localhost:8443
 
# only anna's sites; lf ls -s demo does not show them
lf ls -s anna

Clean up

# remove every test server and its data
try_down
 
# remove keys, config, sites and copied files
rm -rf ~/landfall-try

Open a new shell to work with your real servers again.

Troubleshooting

problemfix
try_up: command not foundThe shell has not loaded the helpers. Run cd ~/landfall-try && . ./try.sh.
port is already allocatedAnother program uses the port. Pick another one in try_up, and use the same ssh port in --port.
Conflict. The container name … is already in useThat test server exists. Use it, or remove all of them with try_down.
try_up never says readyThe container needs --privileged, which some Docker setups refuse. Check docker logs landfall-try-demo.
hello.localhost does not resolveSome systems do not resolve *.localhost. Add 127.0.0.1 hello.localhost to /etc/hosts.
curl: (35) or a TLS errorTraefik answers only names it has a certificate for. Run try_cert demo again.
404 page not foundRight after a deploy, wait a few seconds. Otherwise check the domain with lf sites info hello.
REMOTE HOST IDENTIFICATION HAS CHANGEDA new container has a new host key. Run rm ~/landfall-try/known_hosts.
vps1 does not trust the edgeRun lf traefik behind $(try_ip edge1) -s vps1 -y.
Permission denied (publickey) as annaThe server anna uses the wrong key. It needs ~/landfall-try/anna.
anna cannot run a commandTenants run only their own commands. Server-wide commands need the admin server, demo.

Try your own changes

In a checkout of the repository, use your build of lf and load the helpers from the checkout:

# lf from the checkout, for this shell
pnpm install && pnpm build && alias lf="node $PWD/dist/cli.mjs"
 
# the helpers; the image is built from this checkout
docker build -t landfall-try test/e2e/ubuntu && . test/e2e/ubuntu/try.sh

landfall's end-to-end tests use the same image:

# every section against fresh containers
pnpm e2e
 
# setup, then only these sections and what they build on
E2E_ONLY="multi edge" pnpm e2e