Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(release): reuse prebuilt binaries for docker images

AkitaOnRails762416b15290
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bbf8ccf6..54d41de5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -57,7 +57,13 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- - run: cargo build --release --bin ai-memory
+ - env:
+ TAILWIND_SKIP: "1"
+ run: cargo build --release --bin ai-memory
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ci-ai-memory-linux-x86_64
+ path: target/release/ai-memory
native-packaging:
name: native packaging assets
@@ -66,18 +72,22 @@ jobs:
- uses: actions/checkout@v4
- run: scripts/check-native-packaging.sh
- # End-to-end docker smoke: builds the published image and confirms
- # the binary inside runs. Catches Dockerfile drift (missing COPY,
- # bad ENTRYPOINT) before it lands in production.
+ # End-to-end docker smoke: packages the release-build binary and confirms
+ # the image runs. Catches Dockerfile drift (missing COPY, bad ENTRYPOINT)
+ # before it lands in production without recompiling Rust in Docker.
docker-smoke:
name: docker image smoke
runs-on: ubuntu-latest
needs: release-build
steps:
- uses: actions/checkout@v4
+ - uses: actions/download-artifact@v4
+ with:
+ name: ci-ai-memory-linux-x86_64
+ path: dist/docker/ai-memory-linux-x86_64
- uses: docker/setup-buildx-action@v3
- name: build image (local tag only)
- run: docker build -f docker/Dockerfile -t ai-memory:ci .
+ run: docker build --target runtime-prebuilt-amd64 -f docker/Dockerfile -t ai-memory:ci .
- name: --version smoke
run: docker run --rm ai-memory:ci --version
- name: bundled hooks present
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 32af43fb..50bdc692 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,11 +1,10 @@
name: release
# Triggered when a version tag is pushed, e.g. git push origin v0.3.2.
-# Builds the native Linux release tarball, creates the GitHub Release,
+# Builds native Linux release tarballs, creates the GitHub Release,
# and pushes the Docker image to Docker Hub with both the version tag
-# and `latest` when Docker Hub credentials are configured. The amd64
-# image reuses the native release artifact; arm64 still builds through
-# Docker/QEMU so the published ARM image is exercised in GitHub infra.
+# and `latest` when Docker Hub credentials are configured. Docker images
+# reuse the native release artifacts instead of recompiling in Docker.
#
# Optional publish secrets (set in repo Settings → Secrets and variables → Actions):
# DOCKERHUB_USERNAME — Docker Hub account name
@@ -61,9 +60,19 @@ jobs:
echo "version=${tag_version}" >> "$GITHUB_OUTPUT"
binary:
- name: linux x86_64 binary
+ name: linux ${{ matrix.arch }} binary
needs: validate-version
- runs-on: ubuntu-22.04
+ runs-on: ${{ matrix.runner }}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: x86_64
+ artifact: ai-memory-linux-x86_64
+ runner: ubuntu-22.04
+ - arch: aarch64
+ artifact: ai-memory-linux-aarch64
+ runner: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v4
@@ -77,8 +86,10 @@ jobs:
run: cargo build --release -p ai-memory-cli
- name: Create release tarball
+ env:
+ RELEASE_ARTIFACT: ${{ matrix.artifact }}
run: |
- artifact="ai-memory-linux-x86_64"
+ artifact="$RELEASE_ARTIFACT"
mkdir -p "dist/$artifact"
cp target/release/ai-memory "dist/$artifact/ai-memory"
cp -a hooks "dist/$artifact/hooks"
@@ -98,10 +109,10 @@ jobs:
- uses: actions/upload-artifact@v4
with:
- name: ai-memory-linux-x86_64
+ name: ${{ matrix.artifact }}
path: |
- ai-memory-linux-x86_64.tar.gz
- ai-memory-linux-x86_64.tar.gz.sha256
+ ${{ matrix.artifact }}.tar.gz
+ ${{ matrix.artifact }}.tar.gz.sha256
# Gate the publish on the Docker Hub secrets actually being present, so a
# fresh clone (or a fork) doesn't get a red failing run on every tag. The
@@ -198,18 +209,26 @@ jobs:
docker-arm64:
name: docker arm64 image
- needs: [check-secrets, validate-version]
+ needs: [binary, check-secrets, validate-version]
if: needs.check-secrets.outputs.docker_enabled == 'true'
- runs-on: ubuntu-latest
+ runs-on: ubuntu-22.04-arm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- - uses: docker/setup-qemu-action@v4
+ - uses: actions/download-artifact@v4
with:
- platforms: arm64
+ name: ai-memory-linux-aarch64
+ path: artifacts
+
+ - name: Unpack prebuilt arm64 binary
+ run: |
+ set -euo pipefail
+ mkdir -p dist/docker/ai-memory-linux-aarch64
+ tar -xzf artifacts/ai-memory-linux-aarch64.tar.gz \
+ -C dist/docker/ai-memory-linux-aarch64
- uses: docker/setup-buildx-action@v3
@@ -225,7 +244,7 @@ jobs:
with:
context: .
file: docker/Dockerfile
- target: runtime-source
+ target: runtime-prebuilt-arm64
platforms: linux/arm64
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
provenance: false
@@ -324,7 +343,7 @@ jobs:
echo "## Install" >> body.md
echo '```bash' >> body.md
echo "# Arch Linux (AUR)" >> body.md
- echo "yay -S ai-memory-bin # prebuilt Linux x86_64 binary" >> body.md
+ echo "yay -S ai-memory-bin # prebuilt Linux x86_64/aarch64 binary" >> body.md
echo "yay -S ai-memory # builds from source" >> body.md
echo "" >> body.md
echo "# Docker" >> body.md
@@ -355,8 +374,9 @@ jobs:
- uses: actions/download-artifact@v4
with:
- name: ai-memory-linux-x86_64
+ pattern: ai-memory-linux-*
path: artifacts
+ merge-multiple: true
- name: Install AUR publish tools
run: pacman -Syu --noconfirm --needed base-devel curl git openssh
@@ -370,7 +390,8 @@ jobs:
version="$VERSION"
source_sha="$(curl -fsSL "https://github.com/akitaonrails/ai-memory/archive/refs/tags/v${version}.tar.gz" | sha256sum | awk '{print $1}')"
- bin_sha="$(sha256sum artifacts/ai-memory-linux-x86_64.tar.gz | awk '{print $1}')"
+ bin_x86_sha="$(sha256sum artifacts/ai-memory-linux-x86_64.tar.gz | awk '{print $1}')"
+ bin_arm_sha="$(sha256sum artifacts/ai-memory-linux-aarch64.tar.gz | awk '{print $1}')"
useradd -m aurbuild
chown -R aurbuild:aurbuild "$GITHUB_WORKSPACE"
@@ -393,13 +414,14 @@ jobs:
runuser -u aurbuild -- env \
HOME=/home/aurbuild \
GIT_SSH_COMMAND='ssh -F /home/aurbuild/.ssh/config' \
- bash -s -- "$version" "$source_sha" "$bin_sha" "$GITHUB_WORKSPACE" <<'EOF'
+ bash -s -- "$version" "$source_sha" "$bin_x86_sha" "$bin_arm_sha" "$GITHUB_WORKSPACE" <<'EOF'
set -euo pipefail
version="$1"
source_sha="$2"
- bin_sha="$3"
- workspace="$4"
+ bin_x86_sha="$3"
+ bin_arm_sha="$4"
+ workspace="$5"
workdir="/tmp/ai-memory-aur-publish"
git config --global user.name "ai-memory release bot"
@@ -421,7 +443,8 @@ jobs:
sed -i \
-e "s/^pkgver=.*/pkgver=${version}/" \
-e "s/^pkgrel=.*/pkgrel=1/" \
- -e "s/^sha256sums_x86_64=('.*')/sha256sums_x86_64=('${bin_sha}')/" \
+ -e "s/^sha256sums_x86_64=('.*')/sha256sums_x86_64=('${bin_x86_sha}')/" \
+ -e "s/^sha256sums_aarch64=('.*')/sha256sums_aarch64=('${bin_arm_sha}')/" \
"$bin_pkgbuild"
publish_pkg() {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68912963..9ddd6b56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
-- Docker release publishing now reuses the prebuilt Linux x86_64 release
- artifact for the amd64 image and smoke-tests both amd64 and arm64 images
- after assembling the multi-arch manifest.
+- Docker release publishing now builds Linux x86_64 and aarch64 artifacts once,
+ reuses those artifacts for Docker images, and smoke-tests both amd64 and arm64
+ images after assembling the multi-arch manifest.
+- The AUR `ai-memory-bin` package now supports aarch64 using the prebuilt Linux
+ aarch64 release artifact.
- Docker source builds now use the vendored Tailwind CSS artifact, avoiding
cross-architecture Tailwind CLI cache collisions during multi-arch releases.
diff --git a/README.md b/README.md
index 4506767e..e017e3b6 100644
--- a/README.md
+++ b/README.md
@@ -135,7 +135,7 @@ For native Arch installs, use the AUR packages. They install
user-level systemd units.
```bash
-yay -S ai-memory-bin # prebuilt Linux x86_64 binary
+yay -S ai-memory-bin # prebuilt Linux x86_64/aarch64 binary
yay -S ai-memory # builds from source
```
diff --git a/crates/ai-memory-cli/tests/packaging.rs b/crates/ai-memory-cli/tests/packaging.rs
index a360f1b4..72a27231 100644
--- a/crates/ai-memory-cli/tests/packaging.rs
+++ b/crates/ai-memory-cli/tests/packaging.rs
@@ -66,6 +66,12 @@ fn aur_packages_install_all_native_assets() {
let install = read_repo("packaging/aur/ai-memory.install");
assert!(install.contains("sudo -u ai-memory ai-memory --data-dir /var/lib/ai-memory"));
assert!(!install.contains("sudo ai-memory --data-dir /var/lib/ai-memory"));
+
+ let bin_pkgbuild = read_repo("packaging/aur/PKGBUILD-bin");
+ assert!(bin_pkgbuild.contains("source_x86_64"));
+ assert!(bin_pkgbuild.contains("source_aarch64"));
+ assert!(bin_pkgbuild.contains("linux-x86_64.tar.gz"));
+ assert!(bin_pkgbuild.contains("linux-aarch64.tar.gz"));
}
#[test]
@@ -73,3 +79,22 @@ fn docker_source_build_uses_vendored_tailwind() {
let dockerfile = read_repo("docker/Dockerfile");
assert!(dockerfile.contains("TAILWIND_SKIP=1 cargo build --release -p ai-memory-cli"));
}
+
+#[test]
+fn docker_publish_jobs_use_prebuilt_binaries() {
+ let dockerfile = read_repo("docker/Dockerfile");
+ assert!(dockerfile.contains("FROM runtime-base AS runtime-prebuilt-amd64"));
+ assert!(dockerfile.contains("FROM runtime-base AS runtime-prebuilt-arm64"));
+ assert!(dockerfile.contains("dist/docker/ai-memory-linux-x86_64/ai-memory"));
+ assert!(dockerfile.contains("dist/docker/ai-memory-linux-aarch64/ai-memory"));
+
+ let release = read_repo(".github/workflows/release.yml");
+ assert!(release.contains("artifact: ai-memory-linux-x86_64"));
+ assert!(release.contains("artifact: ai-memory-linux-aarch64"));
+ assert!(release.contains("target: runtime-prebuilt-amd64"));
+ assert!(release.contains("target: runtime-prebuilt-arm64"));
+
+ let ci = read_repo(".github/workflows/ci.yml");
+ assert!(ci.contains("ci-ai-memory-linux-x86_64"));
+ assert!(ci.contains("--target runtime-prebuilt-amd64"));
+}
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 7a3cdc86..e87a9173 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -7,9 +7,9 @@
# owns /data. CA certificates included for outgoing HTTPS (LLM
# providers in M6+).
#
-# The default final target builds the binary from source. Release automation can
-# target `runtime-prebuilt-amd64` after downloading the native release artifact,
-# avoiding a second amd64 compile in the Docker publish job.
+# The default final target builds the binary from source. Release automation and
+# CI can target the prebuilt runtime stages after downloading native release
+# artifacts, avoiding duplicate Rust compiles in Docker jobs.
FROM rust:1.95-slim-bookworm AS builder
WORKDIR /work
@@ -53,7 +53,11 @@ ENTRYPOINT ["/usr/local/bin/ai-memory"]
CMD ["serve", "--transport", "http", "--bind", "0.0.0.0:49374", "--enable-web"]
FROM runtime-base AS runtime-prebuilt-amd64
-COPY dist/docker/ai-memory-linux-x86_64/ai-memory /usr/local/bin/ai-memory
+COPY --chmod=0755 dist/docker/ai-memory-linux-x86_64/ai-memory /usr/local/bin/ai-memory
+USER ai-memory
+
+FROM runtime-base AS runtime-prebuilt-arm64
+COPY --chmod=0755 dist/docker/ai-memory-linux-aarch64/ai-memory /usr/local/bin/ai-memory
USER ai-memory
FROM runtime-base AS runtime-source
diff --git a/docs/install.md b/docs/install.md
index ab7ad122..fda3f6c0 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -118,7 +118,7 @@ with `install-hooks --apply`.
### Package choice
```bash
-yay -S ai-memory-bin # prebuilt Linux x86_64 binary, fastest install
+yay -S ai-memory-bin # prebuilt Linux x86_64/aarch64 binary, fastest install
yay -S ai-memory # builds from source, works on x86_64 and aarch64
```
diff --git a/packaging/aur/PKGBUILD-bin b/packaging/aur/PKGBUILD-bin
index 0b5bc28d..8d5b4752 100644
--- a/packaging/aur/PKGBUILD-bin
+++ b/packaging/aur/PKGBUILD-bin
@@ -5,7 +5,7 @@ _pkgname=ai-memory
pkgver=0.3.2
pkgrel=1
pkgdesc="Local-first long-term memory MCP server for AI coding agents (prebuilt binary)"
-arch=('x86_64')
+arch=('x86_64' 'aarch64')
url="https://github.com/akitaonrails/ai-memory"
license=('MIT')
depends=('ca-certificates' 'gcc-libs' 'glibc')
@@ -20,6 +20,8 @@ options=('!strip' '!debug')
source_x86_64=("$_pkgname-$pkgver-x86_64.tar.gz::$url/releases/download/v$pkgver/$_pkgname-linux-x86_64.tar.gz")
sha256sums_x86_64=('SKIP')
+source_aarch64=("$_pkgname-$pkgver-aarch64.tar.gz::$url/releases/download/v$pkgver/$_pkgname-linux-aarch64.tar.gz")
+sha256sums_aarch64=('SKIP')
package() {
install -Dm0755 ai-memory "$pkgdir/usr/bin/ai-memory"
diff --git a/packaging/aur/README.md b/packaging/aur/README.md
index f30595ad..22c0bfce 100644
--- a/packaging/aur/README.md
+++ b/packaging/aur/README.md
@@ -3,8 +3,8 @@
This directory contains the package definitions for two Arch User Repository
packages:
-- `ai-memory-bin`: installs the prebuilt Linux x86_64 binary and bundled files
- from GitHub Releases.
+- `ai-memory-bin`: installs the prebuilt Linux x86_64/aarch64 binary and bundled
+ files from GitHub Releases.
- `ai-memory`: builds from the GitHub source tag with the local Rust toolchain.
The files here are the source of truth for the AUR repos, but AUR still requires
@@ -15,7 +15,7 @@ each package to be pushed to its own Git repository with a generated `.SRCINFO`.
Use an AUR helper:
```bash
-yay -S ai-memory-bin # prebuilt binary, fastest on x86_64
+yay -S ai-memory-bin # prebuilt binary, fastest on x86_64/aarch64
yay -S ai-memory # builds from source, supports x86_64/aarch64
```
@@ -75,10 +75,7 @@ version=X.Y.Z
# Source package tarball
curl -fsSL "https://github.com/akitaonrails/ai-memory/archive/refs/tags/v${version}.tar.gz" | sha256sum
-# Binary package release artifact
+# Binary package release artifacts
curl -fsSL "https://github.com/akitaonrails/ai-memory/releases/download/v${version}/ai-memory-linux-x86_64.tar.gz.sha256"
+curl -fsSL "https://github.com/akitaonrails/ai-memory/releases/download/v${version}/ai-memory-linux-aarch64.tar.gz.sha256"
```
-
-`ai-memory-bin` is currently `x86_64` only because the release workflow publishes
-a Linux x86_64 binary. The source package includes `aarch64` because it compiles
-locally on Arch Linux ARM.