Building
Yoke's programs are Go, and building them takes the Go toolchain and a clone of the yoke repository
at a release's tag. Every program but yoke-auth is statically linked, and yoke-auth is built
without a C toolchain all the same, so one machine builds for both architectures.
A program states its version from the clone it was built in, which is why the build starts from a
clone and not from the source archive. Go writes into each program the version its module has there:
the tag when the clone is exactly at it, a version derived from the tag and the commit when it is past
it, and +dirty added when the tree holds a file git does not have. A program built where there is no
repository states (devel), which is no version at all, and the manager refuses a Core that states none
when an application is installed, naming the binary. The programs are therefore written outside the
clone, into ~/yoke-stage, so that a second build does not find the first one's files and call the
tree dirty.
Clone the repository at the release's tag:
version=0.14.0
git clone --branch v$version https://github.com/yoke-project/yoke.git
cd yoke
mkdir -p ~/yoke-stage
- Locally
- In a container
This machine needs Go 1.26 or newer and git.
CGO_ENABLED=0 go build -trimpath -o ~/yoke-stage/ ./cmd/yoke ./cmd/yoke-core ./cmd/yoke-guardian ./cmd/yoke-auth ./cmd/yoke-compose
Check the version each program states, before anything runs it:
go version -m ~/yoke-stage/yoke-core | awk '$1 == "mod"'
mod github.com/yoke-project/yoke v0.14.0
For the other architecture, name it — a 64-bit Raspberry Pi OS is arm64 — and build into another
directory, since these programs will not run here:
CGO_ENABLED=0 GOARCH=arm64 go build -trimpath -o ~/yoke-stage-arm64/ ./cmd/yoke ./cmd/yoke-core ./cmd/yoke-guardian ./cmd/yoke-auth
The repository defines the container its build runs in: Containerfile at its root, the Go
toolchain and just on a Debian base. Building in it needs nothing on this machine but a container
engine and git. The image is built once, and the clone is mounted into it at every build, so a change to
the source needs no new image.
- Podman
- Docker
Rootless, the files it writes are yours:
podman build -f Containerfile -t yoke-build .
podman run --rm -e CGO_ENABLED=0 -v "$PWD:/src:Z" -v "$HOME/yoke-stage:/out:Z" -w /src yoke-build \
go build -trimpath -o /out/ ./cmd/yoke ./cmd/yoke-core ./cmd/yoke-guardian ./cmd/yoke-auth ./cmd/yoke-compose
Check the version each program states, before anything runs it:
podman run --rm -v "$HOME/yoke-stage:/out:Z" yoke-build go version -m /out/yoke-core | awk '$1 == "mod"'
Docker runs as root, so run the build as your own account: the files are then yours, git recognises
the clone as yours, and HOME gives the toolchain somewhere to keep its caches.
docker build -f Containerfile -t yoke-build .
docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -e CGO_ENABLED=0 -v "$PWD:/src" -v "$HOME/yoke-stage:/out" -w /src yoke-build \
go build -trimpath -o /out/ ./cmd/yoke ./cmd/yoke-core ./cmd/yoke-guardian ./cmd/yoke-auth ./cmd/yoke-compose
Check the version each program states, before anything runs it:
docker run --rm -v "$HOME/yoke-stage:/out" yoke-build go version -m /out/yoke-core | awk '$1 == "mod"'
mod github.com/yoke-project/yoke v0.14.0
For the other architecture, add -e GOARCH=arm64 to the run, and mount another directory as
/out. Yoke itself does not run in the container: the Core drives a container engine for the units
that ask for one, is watched by the host's init system and learns who is calling from a local socket,
and each of these changes across a container's boundary. What comes out is installed on the host.
The packaging inputs go beside the programs, as a release's archive carries them; the next step
installs from ~/yoke-stage:
cp -r packaging ~/yoke-stage/
Building to change Yoke
Somebody changing Yoke works in a clone at main, not at a tag, and runs the repository's own
commands: just build compiles every package, just test runs every check and test, just lint and
just fmt keep it clean. A program built there states a version derived from the newest tag and the
commit, which is what it is. Contributing says what each command does and what
a change has to pass.
Next: install what was built.