This page is the one place that says how a change gets from the code to your server. When that changes, this page changes in the same pull request.
change → pull request → main → release → GitHub, signed → moin update, when you run it
→ update.sh, when its owner runs it → moin.runA change
One branch, one small thing. Everyone, maintainers too:
- A pull request. Nobody pushes to
main. - CI turns green.
- A maintainer reviews it.
- A squash merge: one commit on
main.
Merging ships nothing. The change only lands on main. Contributing
What ships what
| What changed | What ships it | Who gets it |
|---|---|---|
Only the repository: AGENTS.md, tests, workflows |
nothing, the merge is enough | nobody |
| The site: docs, blog, landing | a release, then its owner rolls it out | moin.run |
What moin does: a feature or a fix |
a release | everyone who updates |
A release has a version, like v1.0.0-beta.38, and its notes in the changelog. The tag v… starts it. Only a release goes live, on moin.run too.
A release
- The notes go into the changelog, then the tag.
- The Deploy workflow tests and builds the
moinbinaries and the image of the site. - It waits until a maintainer approves the run in GitHub.
SHA256SUMSlists the binaries and the image of the site, by its digest. The image holds the deploy files of moin.run, in/deploy.- It signs
SHA256SUMSwithRELEASE_SIGNING_KEY, a secret of the GitHub environmentrelease, twice:SHA256SUMS.sigformoin update,SHA256SUMS.sshsigforssh-keygenincli.shandupdate.sh. Only av*tag reaches the key, and only after that approval. - It makes the GitHub release as a draft, adds every file, and only then publishes it.
So nobody sees a new version before its signed release is complete.
Where moin.run runs
moin.run is one Go app. It has one SQLite database. Both live on one server.
Docker Compose starts it. update.sh runs Compose, not moin. So moin.run never needs moin to come back.
Its traffic comes in through a Cloudflare Tunnel. No port is open.
The server also runs moin’s daemon, as a server without apps. The daemon keeps the firewall shut. It counts the knocks. It reports them. The knocks on the home page are those.
If moin.run is down, only that number is missing. Nothing else needs moin.run.
How moin.run goes live
cloud/deploy/update.sh is moin.run’s own script. If you run moin, you never need it: you update with moin update <server>, and a watcher of your own runs with moin watcher run.
What GitHub does
GitHub only tests, builds, signs and publishes. A release carries only what people who run moin need: the binaries and SHA256SUMS, signed.
The files of the site’s server live in the image of the site, in /deploy: compose.yml, compose.tunnel.yml, litestream.yml, env.example, update.sh, and restore-check.sh with its restore-check.service and restore-check.timer. SHA256SUMS names that image by its digest. So the release key signs these files too.
GitHub never touches the server. Nothing goes live when a release comes out.
What its owner types
One command, from the owner’s laptop:
tailscale ssh root@<server> /opt/moin/update.sh v1.0.0-beta.43
Without a version, it takes the newest release. Step by step, update.sh:
- Downloads
SHA256SUMSof that release, with its signature. - Checks the signature with the release keys written into the script. One wrong byte, and it stops. Nothing changed.
- Pulls the image of the site by the digest
SHA256SUMSnames. Takes the files of the site out of its/deploy. So it runs exactly what the release signed. - Keeps the files of the running version in
previous/. - On a server without a database, brings it back from its bucket.
- Checks the env vars with the new version, while the old one keeps running.
- Starts the new version, and waits until it runs healthy.
- Asks the site at
/healthzif it answers. - Sets up the daily restore check of the database.
Why nothing outside holds a key to the server
No outside service holds a key to the server. GitHub has no SSH key, no Tailscale key, and none of the env vars. It has no key to the bucket of the database either, not even one that only reads.
A stolen GitHub token can’t change moin.run. At most it could publish a release. And the server only starts a release the release key signed, and only when its owner types the command.
When a rollout fails
If a step before 4 fails, nothing changed. The old version keeps running.
If a step from 5 to 8 fails, update.sh puts the files of previous/ back. It starts the previous version again. It says so, clearly, and ends with an error. The new version is not live.
Step 9 comes after the site is live. If it fails, the new version stays live, and update.sh ends with an error.
Go back to an older version
Give update.sh the older version. It rolls it out the same way.
It goes back as far as v1.0.0-beta.47. An older image has no /deploy. update.sh stops there. Nothing changed.
Change the .env
The env vars live in one plain file on the server: /opt/moin/.env. No service fills it. /opt/moin/env.example names every env var, with one line on what it is. Each update puts the one of its version there.
- Edit
/opt/moin/.envon the server. - Run
update.shagain.
The preflight of step 6 stops a missing or wrong env var. Then the running site stays.
The first install
A fresh server needs update.sh once, out of the image the release signed. As root on the server, with Docker installed. First check the signature:
mkdir -p /opt/moin && cd /opt/moin version=v1.0.0-beta.47 url=https://github.com/axadrn/moin/releases/download/$version curl -fsSLO "$url/SHA256SUMS" curl -fsSLO "$url/SHA256SUMS.sshsig" cat > allowed_signers << 'KEYS' moin-release ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZMF3btxHJfEbOLX18SK74qTn0WuUetbX1hHSiEsNyw moin-release ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICtglRxa7QWCtSE+7Pvtv0fy2TcTuvoxj3OvBGYlAyoU KEYS ssh-keygen -Y verify -f allowed_signers -I moin-release -n moin-release -s SHA256SUMS.sshsig < SHA256SUMS
ssh-keygen must say Good "moin-release" signature. Else stop. The keys are the same as in update.sh and in internal/build/release.go.
Then take update.sh and env.example out of the image SHA256SUMS names:
image=ghcr.io/axadrn/moin@sha256:$(awk -v image="ghcr.io/axadrn/moin:$version" '$2 == image { print $1 }' SHA256SUMS)
docker pull "$image"
container=$(docker create "$image")
docker cp "$container:/deploy/update.sh" .
docker cp "$container:/deploy/env.example" .
docker rm "$container"
rm SHA256SUMS SHA256SUMS.sshsig allowed_signersThen write the env vars into /opt/moin/.env, with chmod 600. env.example names them. Then ./update.sh $version.
moin.run’s database
Litestream backs up the database. It runs on its own, next to the site. moin plays no part in it.
- Every change goes to its own bucket within seconds.
- A full snapshot goes there once a day.
- A restore can go back seven days.
A fresh server has no database. Before the site starts, update.sh asks Litestream to bring it back from the bucket. With a database there, it does nothing.
The daily restore check
A backup only counts if it comes back. So every day, the server checks its own. moin does the same for your apps.
restore-check.sh does it, every morning. A systemd timer starts it. update.sh sets the timer up, so it needs no step by hand.
- Litestream brings the newest copy back from the bucket, into a spare file. Same image, same env vars, same bucket.
- SQLite checks the whole file.
- The file must have workspaces.
- The spare file is deleted.
Every check mails its result to the owner, at the address the site sends from: moin.run backup check: OK or moin.run backup check: FAILED, with a few plain lines. One mail a day. A day without one means something is broken.
The mail goes through Cloudflare Email Sending, with the env vars the site already has. No new env var.
The copies in the bucket are not encrypted. So only the server holds a key to the bucket. GitHub holds none, not even one that only reads.
To run the check by hand, from the owner’s laptop:
tailscale ssh root@<server> /opt/moin/restore-check.sh
It says what it found. The daily runs are in journalctl -u restore-check.
Updates
Nothing updates by itself. Not the CLI, not a server, not a watcher.
moin updateupdates the CLI on your laptop, from the GitHub release, after it checked the signature.moin update my-serverputs that same version on the server, over SSH. The server downloads it, checks its signature, and restarts the daemon. Your apps keep running.- Once a day the CLI says when a new version is out.
What a release needs from you, if anything, is in its notes, under Upgrade. Updates
Your version
moin version