Updating

New servers are set up with deploy/install.sh (Install the builder on your server and …), which installs the newest release; this page is about updating them afterwards.

The builder is released as git tags (v1.0.0, v1.1.0, …); CHANGELOG.md says what each release changes and what to do first. deploy/update.sh installs a release on a server: backup, update, build, restart and a health check, and back again with --rollback.

What an update does to live websites

  • Nothing while it runs. Caddy keeps serving the installed websites; only the containers whose image changed restart (a few seconds). The builder is briefly unavailable for editing; a contact form sent in exactly that moment may fail once.
  • The websites stay exactly as they are until a new version of a site is written: when you approve a publish request, a client publishes an entry or a scheduled entry goes live. That version is built with the new release, so changes to elements (layout, CSS, site.js) reach a site with its next update. When a release changes elements, the changelog says so: check a test site first.
  • Database changes are applied automatically when the builder starts. They only go forward: an older release refuses to start on a database a newer one has changed (see going back).

Before you update

  1. Read the release's entry in CHANGELOG.md, especially Before updating.
  2. With a test server (a copy of the stack with LOCAL_CERTS=true and a restored backup), update it first and click through a site or two.
  3. update.sh makes a backup itself (database and uploads, in data/backups/). Copy it off the server as usual.

Update

On the server, in the stack's folder (deploy/server, deploy/builder or deploy/web):

cd /srv/website-builder/deploy/server
GOUTILS_TOKEN=github_pat_... ../update.sh           # the newest release
GOUTILS_TOKEN=github_pat_... ../update.sh v1.2.0    # a given release

The script:

  1. refuses if the repository has local changes (.env and the data folders are ignored);
  2. shows the running and the target version and the changelog, and asks;
  3. makes a backup (stacks with a builder);
  4. checks out the release, builds the image with the version in it, restarts changed containers;
  5. checks that all containers run, the builder answers and the deployer gets the sites.

--yes skips the question (for automation). The running version: Admin → Web servers (top right), docker compose run --rm builder version, or the first line of the log.

Several servers

Update the builder first, then the web servers one at a time (with failover, one of them is always serving). Each web server's release is shown in Admin → Web servers; a different release is fine. If a release changes the hosting protocol (the changelog says so), the list marks web servers as incompatible until they are updated; they keep serving the sites they have.

Going back

GOUTILS_TOKEN=github_pat_... ../update.sh --rollback

returns to the release that ran before the last update. If that update changed the database, the older builder refuses to start (database from a newer release in docker compose logs builder); then also restore the backup the update made:

docker compose down
ls -1t data/backups/                          # builder-<date>.db and uploads-<date>.tar.gz of the update
cp data/backups/builder-<date>.db data/builder.db && rm -f data/builder.db-wal data/builder.db-shm
rm -rf data/uploads && mkdir data/uploads && tar -xzf data/backups/uploads-<date>.tar.gz -C data/uploads
sudo chown -R 65532:65532 data
docker compose up -d

Changes made after the update (edits, new entries) are lost with the restore; the installed websites are not affected.

Making a release (maintainers)

  1. Move the entries under Unreleased in CHANGELOG.md to a new section ## vX.Y.Z, with Before updating notes. Pick the number by the rules at the top of the changelog.

  2. Merge to master, then tag the merge commit and push the tag:

    git checkout master && git pull
    git tag -a v1.1.0 -m "v1.1.0"
    git push origin v1.1.0
    
  3. Optionally create a GitHub release from the tag with the changelog entry.

Servers only install tags, so master can move on between releases. To try master on a test server: ../update.sh origin/master.