~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Each version's image is published as a knotless release

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:release/image
.knotless/workflows/deploy.yml+33−5
@@ -11,10 +11,10 @@
# (hetzner-infra's stacks/opensocial). This run reaches it with
# GROUP_HOST_DEPLOY_KEY, a key the box takes only for its forced command,
# group-host-deploy, which can build group-host from an archive, bring a
# build up, or drop one, and nothing else (hetzner-infra's
# stacks/opensocial/files/group-host-deploy.sh). The key is sealed to
# ci.knotless.dev, the runner that runs only its owner's repositories, for
# pushes to main alone, so no other run sees it.
# build up, drop one, or save the one running, and nothing else
# (hetzner-infra's stacks/opensocial/files/group-host-deploy.sh). The key
# is sealed to ci.knotless.dev, the runner that runs only its owner's
# repositories, for pushes to main alone, so no other run sees it.
#
# The commit is built on the box as group-host:build-<commit>, then goes
# up: the running image is kept as group-host:before-<commit> to roll back
@@ -22,19 +22,30 @@
# then as the network reaches it. Deploys run one at a time, in the order
# main moved (superseded: finish), so none is cut off halfway and an older
# commit never goes up after a newer one.
#
# Once up, the image is published as the release of the `group-host`
# package at main's version, if that version has none yet: `box save`
# streams `docker save` of the running image, an OCI image layout, into
# `knotless release publish --oci`, as the owner, with RELEASE_PASSWORD,
# an app password of theirs sealed to this runner for main alone, the
# version's CHANGELOG.md section as its notes. It is then `docker pull
# knotless.dev/chadtmiller.com/group-host:<version>`, the image
# next.opensocial.fyi runs. Without RELEASE_PASSWORD, nothing is published.
on:
push:
refs: [refs/heads/main]
superseded: finish
runners: [ci.knotless.dev]
image: alpine:3.22
secrets: [GROUP_HOST_DEPLOY_KEY]
secrets: [GROUP_HOST_DEPLOY_KEY, RELEASE_PASSWORD]
env:
# The grain box, which serves next.opensocial.fyi, and its host key, as
# hetzner-infra's ci/known_hosts pins it.
GROUP_HOST_BOX: root@opensocial.fyi
GRAIN_HOST_KEY: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINaUk4YyxTjCsPg1XOsCIJiB1NlEakc9/tnS+QeYRRNQ
GROUP_HOST_URL: https://next.opensocial.fyi
REPO: knotless://chadtmiller.com/group-host
KNOTLESS_APPVIEW: https://knotless.dev
steps:
- name: tools
run: |
@@ -68,3 +79,20 @@ steps:
echo "the box runs group-host:current at this commit, but it is not healthy;"
echo "to roll back: docker tag group-host:before-$(echo "$KNOTLESS_RUN_SHA" | cut -c1-12) group-host:current, then docker compose up -d in /etc/group-host"
exit 1
- name: image
run: |
[ -n "$RELEASE_PASSWORD" ] || { echo "no RELEASE_PASSWORD: not publishing the image"; exit 0; }
curl -fsSL "$KNOTLESS_APPVIEW/install.sh" | KNOTLESS_INSTALL_DIR=/usr/local/bin sh
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if knotless release list "$REPO" group-host | cut -f2 | grep -qxF "$version"; then
echo "group-host $version is published already"
exit 0
fi
dir=$(mktemp -d)
box save | tar -x -C "$dir"
# The version's section of the changelog, less its heading.
awk -v v="$version" '/^## / { on = ($2 == v); next } on' CHANGELOG.md > ~/.notes
KNOTLESS_IDENTIFIER=chadtmiller.com KNOTLESS_PASSWORD="$RELEASE_PASSWORD" \
knotless release publish "$REPO" group-host "$version" --oci "$dir" --commit "$KNOTLESS_RUN_SHA" --notes - < ~/.notes
echo "published: docker pull knotless.dev/chadtmiller.com/group-host:$version"
timeout: 20
docs/design/signing-in.md+1−2
@@ -62,8 +62,7 @@ shows its sign-up. On return the token's `sub` is the account it made,
which nobody named before. So the host resolves it, as it would a typed
handle, and signs you in only if that account's own authorization server
is the one that answered. The sign-in field's example handle is under
the sign-up PDS's own name, `you.bsky.social` or
`you.pds.next.opensocial.fyi`.
the sign-up PDS's own name, such as `you.bsky.social`.
As you type, the field suggests the accounts whose handle matches, with
each one's picture, name and handle where they're known. Picking one
docs/deploying.md+15−11
@@ -10,9 +10,20 @@ A group is an atproto account of its own, with no password and no one person beh
One image, `group-host:current`, carries three programs. The host, `group-host`, is a Rust server over SQLite. The console is a SvelteKit app where people start and run groups, built into `/app/build`. The command is `atgrp`. The host and the console run as two containers from that image, behind one domain.
## Pulling the image
Each released version is published as an image. Pull the one you want, and name it as the steps below do:
```sh
docker pull knotless.dev/chadtmiller.com/group-host:0.2.0
docker tag knotless.dev/chadtmiller.com/group-host:0.2.0 group-host:current
```
`latest` is the highest version. What changed in each is in `CHANGELOG.md`.
## Building the image
Build from the repository root, and name the commit you're building:
Or build it yourself from the repository root, and name the commit you're building:
```sh
docker build --build-arg GROUP_HOST_COMMIT=$(git rev-parse HEAD) -t group-host:current .
@@ -164,10 +175,11 @@ Compose checks the host at `/xrpc/_health` and the console at `/_app/version.jso
## Upgrading
The host's SQLite database holds the groups' repos, spaces and members. The host makes its writes take turns within its own process, so two hosts over one data directory would interleave commits to the same repos. So never run the host twice over one data directory. To upgrade, stop the old host, then start the new one:
The host's SQLite database holds the groups' repos, spaces and members. The host makes its writes take turns within its own process, so two hosts over one data directory would interleave commits to the same repos. So never run the host twice over one data directory. To upgrade, make the new `group-host:current`, pulled or built as above, then stop the old host and start the new one:
```sh
docker build --build-arg GROUP_HOST_COMMIT=$(git rev-parse HEAD) -t group-host:current .
docker pull knotless.dev/chadtmiller.com/group-host:0.2.0
docker tag knotless.dev/chadtmiller.com/group-host:0.2.0 group-host:current
docker compose stop host
docker compose up -d host
docker compose up -d console
@@ -175,14 +187,6 @@ docker compose up -d console
On SIGTERM the host answers the requests already under way, within its 30-second grace period, then exits. The proxy holds new requests until the new host answers. Compose replaces the console the same way. It keeps no state, so a rollout could start a new console beside the old one instead. Neither service sets `container_name`, so that stays possible. When it's stopped, the console finishes its requests within a 35-second grace period.
## Deploying on each merge
The host at next.opensocial.fyi deploys itself: `.knotless/workflows/deploy.yml` runs on each push to `main`. A pull is merged into `main` once its own checks (`check`, `test`, `web`, `lexicons`, `e2e` and `docs`) have passed on it merged with `main`, and the review bot has approved it. So the deploy doesn't wait for `main`'s own checks, since a workflow's step can't read a private repository's checks. The merge queue, which would check each batch as it lands, is off while knotless can't land a private repository's queue. The workflow sends a `git archive` of the commit to the machine over SSH, which builds it as `group-host:build-<commit>`. That image then becomes `group-host:current`, and the image it replaces is kept as `group-host:before-<commit>`. Compose brings the host and the console up from the compose file at that commit, as the upgrade above does. The deploy passes once `/xrpc/_health` names the commit, on the machine and then through the proxy, within a minute.
One deploy runs at a time, in the order `main` moved, and a newer commit's deploy waits for the one before it to finish instead of cutting it off.
The workflow runs only on `ci.knotless.dev`, the runner that runs only its owner's repositories. Every other workflow names `runner.knotless.dev`. One secret is sealed to `ci.knotless.dev` for `refs/heads/main`. It's `GROUP_HOST_DEPLOY_KEY`, an SSH key the machine accepts only to run its deploy command. That command can build, bring up or throw away a group-host image and can't do anything else. The deploy command, how its key is installed, and how to roll back are in the machine's own configuration (hetzner-infra's `stacks/opensocial`).
## Backing up
The data directory holds everything the host knows. There's `host.sqlite`, the database of accounts, repos, spaces, members, tokens and the index. There are the blobs, and there's `host-secrets.json`, which holds the host's keys. `logs.sqlite` and `stats.sqlite`, its logs and counts, need no backing up.
docs/development.md+17−2
@@ -285,5 +285,20 @@ The owner runs it, signed in with `knotless login`, with knope
installed (`cargo install knope`). No workflow can, for the same reason
as the docs site: reading or writing a private repository takes an OAuth
login's space credential, and an app password, all a run could sign in
with, can't get one. For the same reason, nothing is published as a
knotless release: knotless refuses a private repository's releases.
with, can't get one. Each version's image is published by the first
deploy that carries it ([below](#the-deploy-and-its-image)).
## The deploy and its image
The host at next.opensocial.fyi deploys itself: `.knotless/workflows/deploy.yml` runs on each push to `main`. A pull is merged into `main` once its own checks (`check`, `test`, `web`, `lexicons`, `e2e` and `docs`) have passed on it merged with `main`, and the review bot has approved it. The workflow sends a `git archive` of the commit to the machine over SSH, which builds it as `group-host:build-<commit>`. That image then becomes `group-host:current`, and the image it replaces is kept as `group-host:before-<commit>`. Compose brings the host and the console up from the compose file at that commit, as [an upgrade](deploying.md#upgrading) does. The deploy passes once `/xrpc/_health` names the commit, on the machine and then through the proxy, within a minute.
One deploy runs at a time, in the order `main` moved, and a newer commit's deploy waits for the one before it to finish instead of cutting it off.
The workflow runs only on `ci.knotless.dev`, the runner that runs only its owner's repositories. Every other workflow names `runner.knotless.dev`. Two secrets are sealed to `ci.knotless.dev` for `refs/heads/main`. `GROUP_HOST_DEPLOY_KEY` is an SSH key the machine accepts only to run its deploy command. That command can build, bring up or throw away a group-host image, or save the one running, and can't do anything else. The deploy command, how its key is installed, and how to roll back are in the machine's own configuration (hetzner-infra's `stacks/opensocial`). `RELEASE_PASSWORD` is an app password of the owner's, for publishing the image.
Once a deploy is up, the workflow publishes the image it runs as the release of the `group-host` package at `main`'s version, unless that version is published already. So each version is published once, by the first deploy that carries it, with its `CHANGELOG.md` section as the release's notes. The image is `docker save` of `group-host:current` on the machine, an OCI image layout, published with `knotless release publish --oci`, and [pulled](deploying.md#pulling-the-image) from knotless.dev. Without `RELEASE_PASSWORD`, the deploy publishes nothing. The owner seals it once, an app password of theirs on stdin, to the trusted runner for `main` alone:
```sh
knotless secret set knotless://chadtmiller.com/group-host RELEASE_PASSWORD \
--runner ci.knotless.dev --ref refs/heads/main
```
AGENTS.md+3−2
@@ -224,8 +224,9 @@ the same commit to a private copy on GitHub
(github.com/bluesky-social/group-host), for those who read the code
there. Nothing is pushed to that copy but from here. `deploy`: each push
to `main`, which takes a pull only once its checks pass,
is built on the machine serving next.opensocial.fyi and goes up there
(`docs/deploying.md`). Every workflow but `deploy` names
is built on the machine serving next.opensocial.fyi and goes up there,
its image published as a knotless release the first time a version goes
up (`docs/development.md`). Every workflow but `deploy` names
`runner.knotless.dev`; `deploy` alone runs on `ci.knotless.dev`, which
runs only its owner's repositories, and holds its secrets.