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

Each release's image is built and published here; nothing here deploys

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:release/image-build
.knotless/workflows/check.yml+1−1
@@ -6,7 +6,7 @@
# lints land on purpose. The build, the toolchain's components and
# cargo-deny are kept between runs, so a push lints only what it changed.
image: rust:1.100
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
# A pre-flight: the merge queue takes a pull into a batch only once this
# has passed at its head, so one that does not build fails no batch.
.knotless/workflows/deploy.ymldeleted+0−98
@@ -1,98 +0,0 @@
# Deploys main to next.opensocial.fyi on each push.
#
# A pull is merged into main once its checks pass on it merged with main,
# and the review bot approves it, so this does not wait for main's own
# checks. It couldn't: a step can't read a private repository's checks
# (knotless issue at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzlv5ic46umh).
# The merge queue is off while knotless can't land a private repository's
# queue through its gateway.
#
# The host runs on the grain box as the compose project /etc/group-host
# (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, 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
# to, and the host must name this commit in /xrpc/_health, on the box and
# 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, 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: |
apk add --no-cache curl git openssh-client >/dev/null
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "$GROUP_HOST_DEPLOY_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "opensocial.fyi $GRAIN_HOST_KEY" > ~/.ssh/known_hosts
printf 'Host *\n StrictHostKeyChecking yes\n ServerAliveInterval 30\n' > ~/.ssh/config
# The box's forced command, given what to do and this commit.
cat > /usr/local/bin/box <<'EOF'
#!/bin/sh
exec ssh "$GROUP_HOST_BOX" "$1 $KNOTLESS_RUN_SHA"
EOF
chmod +x /usr/local/bin/box
- name: build
run: |
git config --global --add safe.directory "$PWD"
git archive --format=tar "$KNOTLESS_RUN_SHA" | box build
timeout: 30
- name: deploy
run: |
box up
# As the network reaches it, through the proxy: the host names this
# commit within a minute, as it restarts, or the deploy fails.
for i in $(seq 30); do
health=$(curl -fsS "$GROUP_HOST_URL/xrpc/_health" || true)
case "$health" in *"\"$KNOTLESS_RUN_SHA\""*) echo "$health"; exit 0 ;; esac
sleep 2
done
echo "$GROUP_HOST_URL names no $KNOTLESS_RUN_SHA: ${health:-no answer}"
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
.knotless/workflows/docs.yml+1−1
@@ -5,7 +5,7 @@
# run could sign in with, cannot write. The site's packages are kept
# between runs and installed again only when its lockfile changes.
image: node:24.22.1
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
# Pushes to main, and pulls that change the docs, their check, the site,
# the lexicons and tokens it takes, or this file. A pull changing none
.knotless/workflows/e2e.yml+1−1
@@ -15,7 +15,7 @@
# and the build are kept between runs, as main's runs leave them: nothing
# is fetched again until what it is made from changes.
image: rust:1.100
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
# Every push to main, and pulls into it or a feature/ branch that change
# the console, the host it asks, the
.knotless/workflows/lexicons.yml+1−1
@@ -2,7 +2,7 @@
# see, and that they only grow from main's (harness/lexicons.mjs). goat is
# kept between runs.
image: node:24.22.1
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
on:
push: {refs: [refs/heads/main]}
.knotless/workflows/mirror.yml+1−1
@@ -10,7 +10,7 @@
on:
push: {refs: [refs/heads/main, refs/tags/*]}
image: debian:stable-slim
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
secrets: [MIRROR_KEY]
env: {MIRROR: git@github.com:bluesky-social/group-host.git}
.knotless/workflows/release.ymlnew+102−0
@@ -0,0 +1,102 @@
# Publishes the host's image once main's version, in Cargo.toml, has no
# release yet and the checks have passed at its commit: the release of the
# package `group-host`, named as the repository, `docker pull
# knotless.dev/chadtmiller.com/group-host:<version>`, with the version's
# CHANGELOG.md section as its notes and the commit it was built from.
# Where it runs is not this repository's to say: next.opensocial.fyi pulls
# the version hetzner-infra names.
#
# The host, the command and the console are built as the Dockerfile builds
# them, and the image made from them with no container engine, which this
# runner's jobs have none of (.knotless/image.sh). `just release` keeps a
# pull open that raises the version; once it lands, this publishes it, and
# the next `just release` tags it. A version CHANGELOG.md has no section
# for is no release (knope writes one for each), so a pull that touches
# Cargo.toml for another reason publishes nothing, and a version published
# already is left alone.
#
# RELEASE_PASSWORD is an app password of the owner's, sealed to this runner
# for pushes to main alone. Asked for on another branch, `knotless run
# rerun knotless://chadtmiller.com/group-host --ref refs/heads/<branch>
# --workflow release`, it builds the image and publishes nothing.
# Bookworm, as the Dockerfile builds and the image's base is: built on a
# newer Debian, the binaries would ask for a glibc the base has not.
image: rust:1.100-bookworm
runners: [runner.knotless.dev]
on:
push: {refs: [refs/heads/main], paths: [Cargo.toml]}
asked: {refs: [refs/heads/*]}
after: [check, test, web, lexicons, e2e, docs]
superseded: finish
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/tools, web/node_modules]
secrets: [RELEASE_PASSWORD]
env:
# The image's toolchain, over the cached rustup's default (check.yml).
RUSTUP_TOOLCHAIN: "1.100.0"
REPO: knotless://chadtmiller.com/group-host
KNOTLESS_APPVIEW: https://knotless.dev
CRANE_VERSION: 0.22.1
CRANE_SHA256: 0ab7a1d6932a213aed964ce97666c3077fe691c8606413674a8b3e0b9ec4cda0
TINI_VERSION: 0.19.0
TINI_SHA256: c5b0666b4cb676901f90dfcb37106783c5fe2077b04590973b885950611b30ee
steps:
- name: version
run: |
curl -fsSL https://knotless.dev/install.sh | KNOTLESS_INSTALL_DIR=/usr/local/bin sh
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
echo "$version" > ~/.version
if knotless release list "$REPO" group-host | cut -f2 | grep -qxF "$version"; then
echo "group-host $version is published already"
touch ~/.done
elif ! grep -q "^## $version " CHANGELOG.md; then
echo "CHANGELOG.md has no section for $version: no release to publish"
[ "$KNOTLESS_RUN_REF" != refs/heads/main ] || touch ~/.done
elif [ "$KNOTLESS_RUN_REF" != refs/heads/main ]; then
echo "on $KNOTLESS_RUN_REF: building $version, publishing nothing"
fi
- uses: chadtmiller.com/steps/node@1
with: {version: 24.22.1}
- uses: chadtmiller.com/steps/npm-ci@1
with: {dir: web}
# The console, then the host and the command: as the Dockerfile's
# stages build them, the commit compiled into the host.
- name: build
run: |
[ ! -e ~/.done ] || exit 0
(cd web && PATH=/opt/node/bin:$PATH npm run build)
# A target directory of its own, so nothing a build on another
# Debian left in the cache is taken for this one.
GROUP_HOST_COMMIT=$KNOTLESS_RUN_SHA cargo build --profile deploy --locked \
--target-dir target/bookworm -p group-host --bin group-host -p atgrp --bin atgrp
timeout: 45
- name: image
run: |
[ ! -e ~/.done ] || exit 0
mkdir -p /opt/tools/bin
if [ "$(cat /opt/tools/.crane 2>/dev/null)" != "$CRANE_VERSION" ]; then
cd /tmp
curl -fsSLO "https://github.com/google/go-containerregistry/releases/download/v$CRANE_VERSION/go-containerregistry_Linux_x86_64.tar.gz"
echo "$CRANE_SHA256 go-containerregistry_Linux_x86_64.tar.gz" | sha256sum -c -
tar -xzf go-containerregistry_Linux_x86_64.tar.gz -C /opt/tools/bin crane
echo "$CRANE_VERSION" > /opt/tools/.crane
cd - > /dev/null
fi
if [ "$(cat /opt/tools/.tini 2>/dev/null)" != "$TINI_VERSION" ]; then
curl -fsSL -o /opt/tools/bin/tini-static "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-static-amd64"
echo "$TINI_SHA256 /opt/tools/bin/tini-static" | sha256sum -c -
echo "$TINI_VERSION" > /opt/tools/.tini
fi
command -v jq > /dev/null || { apt-get update -qq && apt-get install -y -qq --no-install-recommends jq > /dev/null; }
git config --global --add safe.directory "$PWD"
PATH=/opt/tools/bin:$PATH SOURCE_DATE_EPOCH=$(git log -1 --format=%ct HEAD) TINI=/opt/tools/bin/tini-static \
.knotless/image.sh target/bookworm/deploy web "$(cat ~/.version)" "$KNOTLESS_RUN_SHA" target/image
- name: publish
on: {refs: [refs/heads/main]}
run: |
[ ! -e ~/.done ] || exit 0
version=$(cat ~/.version)
owner=${REPO#knotless://}
export KNOTLESS_IDENTIFIER=${owner%%/*} KNOTLESS_PASSWORD="$RELEASE_PASSWORD"
# The version's section of the changelog, less its heading.
awk -v v="$version" '/^## / { on = ($2 == v); next } on' CHANGELOG.md > ~/.notes
knotless release publish "$REPO" group-host "$version" --oci target/image --commit "$KNOTLESS_RUN_SHA" --notes - < ~/.notes
.knotless/workflows/test.yml+1−1
@@ -8,7 +8,7 @@
# are kept between runs; each is made again only when what it is made from
# changes.
image: rust:1.100
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
# A pre-flight, as check is: the merge queue takes a pull into a batch only
# once this has passed at its head.
.knotless/workflows/web.yml+1−1
@@ -6,7 +6,7 @@
# svelte-check, which fails on any warning. The packages are kept between
# runs and installed again only when a lockfile changes.
image: node:24.22.1
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
# The shared runner host, as every workflow here.
runners: [runner.knotless.dev]
# Pushes to main, and pulls that change the pages, the lexicons their
# types are made from, the harness, the docs site,
.knotless/image.shnew+112−0
@@ -0,0 +1,112 @@
#!/bin/sh
# The host's image as an OCI image layout, made with no container engine,
# as release.yml's runner gives its jobs none. It is the Dockerfile's last
# stage: node:24.22.1-bookworm-slim for linux/amd64, as the registry has it
# when this runs, and one layer more holding the host, the command, the
# console, tini and the CA bundle, with the Dockerfile's user, environment,
# working directory, entry point and command. The image's labels, and its
# manifest's annotations, name its version, the commit it was built from
# and the base, by digest.
#
# SOURCE_DATE_EPOCH=<commit time> TINI=<tini-static> \
# .knotless/image.sh <bins> <console> <version> <commit> <dir>
#
# <bins> holds group-host and atgrp, built for linux/amd64 against
# bookworm's glibc; <console> is web/, built (its build/ and package.json).
# The layer's files and the image's dates are SOURCE_DATE_EPOCH's, so the
# same build on the same base makes the same image. Needs crane, jq, GNU
# tar, gzip and sha256sum.
set -eu
bins=$1 console=$2 version=$3 commit=$4 out=$5
: "${SOURCE_DATE_EPOCH:?the commit's time, in seconds}"
: "${TINI:?a static tini, as the Dockerfile's apt-get installs it}"
base=node:24.22.1-bookworm-slim
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
blob() { echo "$work/base/blobs/sha256/${1#sha256:}"; }
digest=$(crane digest --platform linux/amd64 "$base")
crane pull --format=oci "$base@$digest" "$work/base"
manifest=$(blob "$(jq -r '.manifests[0].digest' "$work/base/index.json")")
jq -e '.mediaType == "application/vnd.oci.image.manifest.v1+json"
and all(.layers[]; .mediaType == "application/vnd.oci.image.layer.v1.tar+gzip")' \
"$manifest" >/dev/null || { echo "$base@$digest: not an OCI image of gzipped layers" >&2; exit 1; }
# The layer: what the Dockerfile's last stage adds to the base. The base
# has the node user (1000) the image runs as, who owns /data.
root="$work/root"
mkdir -p "$root/usr/local/bin" "$root/usr/bin" "$root/etc/ssl/certs" "$root/app" "$root/data"
install -m 755 "$bins/group-host" "$bins/atgrp" "$root/usr/local/bin/"
install -m 755 "$TINI" "$root/usr/bin/tini"
install -m 644 /etc/ssl/certs/ca-certificates.crt "$root/etc/ssl/certs/"
cp -R "$console/build" "$root/app/build"
install -m 644 "$console/package.json" "$root/app/package.json"
chown -R 0:0 "$root"
chown 1000:1000 "$root/data"
tar -C "$root" -cf "$work/layer.tar" --sort=name --mtime="@$SOURCE_DATE_EPOCH" \
--numeric-owner --format=posix --pax-option=delete=atime,delete=ctime app data etc usr
diff_id=$(sha256sum "$work/layer.tar" | cut -d' ' -f1)
gzip -9n < "$work/layer.tar" > "$work/layer.tar.gz"
created=$(date -u -d "@$SOURCE_DATE_EPOCH" +%Y-%m-%dT%H:%M:%SZ)
jq --arg diff "sha256:$diff_id" --arg created "$created" \
--arg version "$version" --arg commit "$commit" --arg base "docker.io/library/$base" --arg digest "$digest" '
.created = $created
| .rootfs.diff_ids += [$diff]
| .history = (.history // []) + [{created: $created, created_by: "the host, the command and the console (.knotless/image.sh)"}]
| .config.User = "node"
| .config.Env = (.config.Env // []) + ["DATA_DIR=/data", "PORT=2600"]
| .config.WorkingDir = "/app"
| .config.Entrypoint = ["tini", "--"]
| .config.Cmd = ["group-host"]
| .config.Labels = (.config.Labels // {}) + {
"org.opencontainers.image.title": "group-host",
"org.opencontainers.image.licenses": "MIT OR Apache-2.0",
"org.opencontainers.image.version": $version,
"org.opencontainers.image.revision": $commit,
"org.opencontainers.image.source": "https://knotless.dev/chadtmiller.com/group-host",
"org.opencontainers.image.base.name": $base,
"org.opencontainers.image.base.digest": $digest
}' "$(blob "$(jq -r '.config.digest' "$manifest")")" > "$work/config.json"
# The layout: the base's layers, the new one, the config, the manifest and
# an index naming it alone.
rm -rf "$out"
mkdir -p "$out/blobs/sha256"
put() {
d=$(sha256sum "$1" | cut -d' ' -f1)
cp "$1" "$out/blobs/sha256/$d"
echo "$d $(wc -c < "$1" | tr -d ' ')"
}
for layer in $(jq -r '.layers[].digest' "$manifest"); do cp "$(blob "$layer")" "$out/blobs/sha256/"; done
read -r layer_d layer_n <<EOF
$(put "$work/layer.tar.gz")
EOF
read -r config_d config_n <<EOF
$(put "$work/config.json")
EOF
jq --arg ld "sha256:$layer_d" --argjson ln "$layer_n" --arg cd "sha256:$config_d" --argjson cn "$config_n" \
--arg version "$version" --arg commit "$commit" --arg base "docker.io/library/$base" --arg digest "$digest" '
.config = {mediaType: "application/vnd.oci.image.config.v1+json", digest: $cd, size: $cn}
| .layers += [{mediaType: "application/vnd.oci.image.layer.v1.tar+gzip", digest: $ld, size: $ln}]
| .annotations = {
"org.opencontainers.image.version": $version,
"org.opencontainers.image.revision": $commit,
"org.opencontainers.image.base.name": $base,
"org.opencontainers.image.base.digest": $digest
}' "$manifest" > "$work/manifest.json"
read -r manifest_d manifest_n <<EOF
$(put "$work/manifest.json")
EOF
jq -n --arg d "sha256:$manifest_d" --argjson n "$manifest_n" --arg version "$version" '{
schemaVersion: 2,
mediaType: "application/vnd.oci.image.index.v1+json",
manifests: [{
mediaType: "application/vnd.oci.image.manifest.v1+json", digest: $d, size: $n,
platform: {architecture: "amd64", os: "linux"},
annotations: {"org.opencontainers.image.ref.name": $version}
}]
}' > "$out/index.json"
echo '{"imageLayoutVersion":"1.0.0"}' > "$out/oci-layout"
echo "$out: group-host $version at $commit on $base@$digest, manifest sha256:$manifest_d"
docs/development.md+14−17
AGENTS.md+5−7
Dockerfile+2−0