feat: publish the Docker image for ARM as well

The image is now made for amd64 and for arm64, and each tag (X.Y.Z, X.Y,
latest) points at both, so a Raspberry Pi or an ARM NAS pulls the right one.

- Dockerfile: the web and Go stages run on the builder and the Go program is
  cross-compiled (GOARCH from SONDA_ARCH or TARGETARCH); what the image needs
  besides the program (time zones, the user, the folders) is made in a stage
  of the builder, so the last stage runs no command and needs no emulation.
- release workflow: the runner has no Docker and cannot run ARM, and kaniko
  takes the base of every stage for one platform, so the arm64 image starts
  from the arm64 Alpine by digest (found at each release), kaniko builds one
  image per architecture, and crane sets the architecture of each and joins
  them under the tags.
This commit is contained in:
tgiachi 2026-11-16 14:33:41 +01:00
commit b37e3db037

View file

@ -65,7 +65,7 @@ A plain `go build -o bin/sondad ./cmd/sondad` needs no Node and gives the API on
The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`.
The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:<commit>` (the first seven characters of a commit of `main`) is one you can stay on. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`.
The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:0.3.0` (a version from [CHANGELOG.md](CHANGELOG.md)) is one you can stay on. It runs on amd64 and on arm64 (a Raspberry Pi, an ARM NAS): one tag gives each machine its own. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`.
```bash
docker pull git.kmalloc.org/squid/sonda:latest
@ -415,7 +415,7 @@ Every merge into `main` can make a release, by itself (`.forgejo/workflows/relea
| `feat!: ...`, or `BREAKING CHANGE:` in the body | major (0.2.0 to 1.0.0) |
| `docs:`, `test:`, `chore:`, `ci:`, `style:` | none by themselves |
A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The runner has no Docker, so the image is built with [kaniko](https://github.com/GoogleContainerTools/kaniko). The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`.
A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The image is made for amd64 and for arm64, and each tag points at both. The runner has no Docker and cannot emulate ARM, so the images are built with [kaniko](https://github.com/GoogleContainerTools/kaniko): the Go program is compiled for ARM with no emulation, the last stage of the Dockerfile runs no command, and a last job (with [crane](https://github.com/google/go-containerregistry)) says the architecture of each image and joins them. The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`.
## Development