From c505142426bdfd882351191aea126669a702bbda Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 15:44:33 +0530 Subject: [PATCH 1/4] ci: publish the Docker image to Docker Hub on release Builds deploy/Dockerfile at the release tag for linux/amd64 and linux/arm64 and pushes ghumarerohit/agentmemory with the version tag, plus latest for stable releases. A linux/amd64 build is started first and must answer /agentmemory/livez before anything is pushed. Images carry OCI labels, provenance and an SBOM. workflow_dispatch back-fills a given version. deploy/README.md documents the prebuilt image. --- .github/workflows/docker-image.yml | 131 +++++++++++++++++++++++++++++ deploy/README.md | 14 +++ 2 files changed, 145 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000000..e13cd8a812 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,131 @@ +name: Docker image + +on: + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: "Release version to build, without the leading v (for example 0.9.32)" + required: true + type: string + latest: + description: "Also tag the image as latest" + required: false + type: boolean + default: false + +permissions: + contents: read + +concurrency: + group: docker-image-${{ github.event.release.tag_name || inputs.version }} + cancel-in-progress: false + +env: + IMAGE: ghumarerohit/agentmemory + +jobs: + image: + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - name: Resolve version + id: v + env: + EVENT: ${{ github.event_name }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + PRERELEASE: ${{ github.event.release.prerelease }} + INPUT_VERSION: ${{ inputs.version }} + INPUT_LATEST: ${{ inputs.latest }} + run: | + if [ "$EVENT" = "release" ]; then + tag="$RELEASE_TAG" + version="${tag#v}" + if [ "$PRERELEASE" = "true" ]; then latest=false; else latest=true; fi + else + version="${INPUT_VERSION#v}" + tag="v${version}" + latest="$INPUT_LATEST" + fi + if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then + echo "Not a release version: $version" >&2 + exit 1 + fi + { + echo "version=$version" + echo "tag=$tag" + echo "latest=$latest" + } >> "$GITHUB_OUTPUT" + + - uses: actions/checkout@v6 + with: + ref: refs/tags/${{ steps.v.outputs.tag }} + persist-credentials: false + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - name: Image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + tags: | + type=raw,value=${{ steps.v.outputs.version }} + type=raw,value=latest,enable=${{ steps.v.outputs.latest }} + labels: | + org.opencontainers.image.version=${{ steps.v.outputs.version }} + org.opencontainers.image.licenses=Apache-2.0 + + - name: Build for smoke test + uses: docker/build-push-action@v6 + with: + context: . + file: deploy/Dockerfile + platforms: linux/amd64 + load: true + tags: agentmemory-smoke:${{ steps.v.outputs.version }} + cache-from: type=gha,scope=docker-image + cache-to: type=gha,scope=docker-image,mode=max + + - name: Smoke test + env: + SMOKE_IMAGE: agentmemory-smoke:${{ steps.v.outputs.version }} + run: | + docker run -d --name am-smoke -p 127.0.0.1:3111:3111 "$SMOKE_IMAGE" + for i in $(seq 1 90); do + if curl -fsS http://127.0.0.1:3111/agentmemory/livez >/dev/null; then + echo "livez ok after $((i * 2)) s" + docker rm -f am-smoke >/dev/null + exit 0 + fi + if [ "$(docker inspect -f '{{.State.Running}}' am-smoke)" != "true" ]; then + echo "container exited" >&2 + break + fi + sleep 2 + done + docker logs am-smoke >&2 || true + docker rm -f am-smoke >/dev/null || true + exit 1 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: deploy/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + provenance: mode=max + sbom: true + cache-from: type=gha,scope=docker-image + cache-to: type=gha,scope=docker-image,mode=max diff --git a/deploy/README.md b/deploy/README.md index c1c7535215..be5acca8b3 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -24,6 +24,20 @@ AGENTMEMORY_REST_PORT=3611 AGENTMEMORY_VIEWER_PORT=3613 docker compose up --buil Open `http://127.0.0.1:3613`, use the persisted secret in `docker compose exec agentmemory cat /data/secret`, and stop with `docker compose down`. `docker compose down -v` deletes the memories and secret. Set `AGENTMEMORY_SECRET` to provide an explicit REST bearer. To use Redis for state, set `AGENTMEMORY_STATE_BACKEND=redis` and `AGENTMEMORY_REDIS_URL=redis://...`; otherwise the persistent file-backed store is used. +## Prebuilt image + +Each published release is also available as a prebuilt image on Docker Hub, built from this Dockerfile at the release tag for `linux/amd64` and `linux/arm64`: + +```bash +docker pull ghumarerohit/agentmemory: +docker run -d --name agentmemory \ + -p 127.0.0.1:3111:3111 -p 127.0.0.1:3113:3113 \ + -v agentmemory-data:/data \ + ghumarerohit/agentmemory: +``` + +Keep `/data` on a persistent volume: it holds the memories, the generated secret (`docker exec agentmemory cat /data/secret`) and the worker cache. The container fetches the pinned `state` and `http` registry workers on first start, so it needs network access then. Set `AGENTMEMORY_SECRET`, `EMBEDDING_PROVIDER` and the other variables from the sections above with `-e`. The `latest` tag follows the newest stable release; pin a version tag for deployments. + ## Local embeddings Set `EMBEDDING_PROVIDER=local` to generate embeddings without an API key. The shared image includes `@huggingface/transformers` and its runtime dependencies; the image build checks that the package loads after pruning development dependencies. Only ONNX native binaries for the image's platform and architecture are retained; other runtime dependencies remain installed. Model weights are not bundled: the first embedding request downloads `Xenova/all-MiniLM-L6-v2` from Hugging Face and requires network access. From 43a24e29706c216ee1c9adffb29b2b2650fe704e Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 15:58:30 +0530 Subject: [PATCH 2/4] ci: build the Docker image without secrets and push it from a separate job - build runs the release tag code with no secrets or registry login and hands an OCI archive to publish as an artifact. - publish runs in the docker-hub environment without checking out the repository, pushes with skopeo, verifies both platforms and attests build provenance for the pushed digest. - latest is a serialized job that points latest at the release GitHub marks as Latest, so an older or delayed release cannot replace it. --- .github/workflows/docker-image.yml | 133 ++++++++++++++++++++++------- deploy/README.md | 2 +- 2 files changed, 103 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e13cd8a812..539e0378d4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,44 +9,33 @@ on: description: "Release version to build, without the leading v (for example 0.9.32)" required: true type: string - latest: - description: "Also tag the image as latest" - required: false - type: boolean - default: false permissions: contents: read -concurrency: - group: docker-image-${{ github.event.release.tag_name || inputs.version }} - cancel-in-progress: false - env: - IMAGE: ghumarerohit/agentmemory + IMAGE: docker.io/ghumarerohit/agentmemory jobs: - image: + build: runs-on: ubuntu-latest timeout-minutes: 90 + permissions: + contents: read + outputs: + version: ${{ steps.v.outputs.version }} steps: - name: Resolve version id: v env: EVENT: ${{ github.event_name }} RELEASE_TAG: ${{ github.event.release.tag_name }} - PRERELEASE: ${{ github.event.release.prerelease }} INPUT_VERSION: ${{ inputs.version }} - INPUT_LATEST: ${{ inputs.latest }} run: | if [ "$EVENT" = "release" ]; then - tag="$RELEASE_TAG" - version="${tag#v}" - if [ "$PRERELEASE" = "true" ]; then latest=false; else latest=true; fi + version="${RELEASE_TAG#v}" else version="${INPUT_VERSION#v}" - tag="v${version}" - latest="$INPUT_LATEST" fi if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then echo "Not a release version: $version" >&2 @@ -54,8 +43,7 @@ jobs: fi { echo "version=$version" - echo "tag=$tag" - echo "latest=$latest" + echo "tag=v$version" } >> "$GITHUB_OUTPUT" - uses: actions/checkout@v6 @@ -74,7 +62,6 @@ jobs: images: ${{ env.IMAGE }} tags: | type=raw,value=${{ steps.v.outputs.version }} - type=raw,value=latest,enable=${{ steps.v.outputs.latest }} labels: | org.opencontainers.image.version=${{ steps.v.outputs.version }} org.opencontainers.image.licenses=Apache-2.0 @@ -111,21 +98,105 @@ jobs: docker rm -f am-smoke >/dev/null || true exit 1 - - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push + - name: Build multi-platform archive uses: docker/build-push-action@v6 with: context: . file: deploy/Dockerfile platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - provenance: mode=max - sbom: true + provenance: false + sbom: false + outputs: type=oci,dest=${{ runner.temp }}/image.tar cache-from: type=gha,scope=docker-image cache-to: type=gha,scope=docker-image,mode=max + + - uses: actions/upload-artifact@v4 + with: + name: agentmemory-image-${{ steps.v.outputs.version }} + path: ${{ runner.temp }}/image.tar + retention-days: 1 + if-no-files-found: error + + publish: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 30 + environment: docker-hub + permissions: + contents: read + id-token: write + attestations: write + env: + VERSION: ${{ needs.build.outputs.version }} + steps: + - uses: actions/download-artifact@v4 + with: + name: agentmemory-image-${{ needs.build.outputs.version }} + path: ${{ runner.temp }}/image + + - name: Log in to Docker Hub + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + run: | + printf '%s' "$DOCKERHUB_TOKEN" | skopeo login --username "$DOCKERHUB_USERNAME" --password-stdin docker.io + printf '%s' "$DOCKERHUB_TOKEN" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin docker.io + + - name: Push version tag + id: push + run: | + skopeo copy --all --preserve-digests \ + --digestfile "$RUNNER_TEMP/digest" \ + "oci-archive:$RUNNER_TEMP/image/image.tar" \ + "docker://$IMAGE:$VERSION" + echo "digest=$(cat "$RUNNER_TEMP/digest")" >> "$GITHUB_OUTPUT" + + - name: Verify platforms + run: | + platforms=$(docker buildx imagetools inspect --raw "$IMAGE:$VERSION" \ + | jq -r '.manifests[].platform | "\(.os)/\(.architecture)"' | sort -u | tr '\n' ' ') + echo "platforms: $platforms" + for p in linux/amd64 linux/arm64; do + case " $platforms " in + *" $p "*) ;; + *) echo "missing $p in $IMAGE:$VERSION" >&2; exit 1 ;; + esac + done + + - uses: actions/attest-build-provenance@v4 + with: + subject-name: ${{ env.IMAGE }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + latest: + needs: publish + runs-on: ubuntu-latest + timeout-minutes: 15 + environment: docker-hub + permissions: + contents: read + concurrency: + group: docker-hub-latest + cancel-in-progress: false + steps: + - name: Log in to Docker Hub + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + run: printf '%s' "$DOCKERHUB_TOKEN" | skopeo login --username "$DOCKERHUB_USERNAME" --password-stdin docker.io + + - name: Point latest at the newest stable release + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + tag=$(gh api "repos/$REPO/releases/latest" --jq .tag_name) + newest="${tag#v}" + if ! skopeo inspect --raw "docker://$IMAGE:$newest" >/dev/null 2>&1; then + echo "Image for the newest stable release ($newest) is not pushed yet; leaving latest unchanged." + exit 0 + fi + skopeo copy --all --preserve-digests "docker://$IMAGE:$newest" "docker://$IMAGE:latest" + echo "latest -> $newest" diff --git a/deploy/README.md b/deploy/README.md index be5acca8b3..048cca94d5 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -36,7 +36,7 @@ docker run -d --name agentmemory \ ghumarerohit/agentmemory: ``` -Keep `/data` on a persistent volume: it holds the memories, the generated secret (`docker exec agentmemory cat /data/secret`) and the worker cache. The container fetches the pinned `state` and `http` registry workers on first start, so it needs network access then. Set `AGENTMEMORY_SECRET`, `EMBEDDING_PROVIDER` and the other variables from the sections above with `-e`. The `latest` tag follows the newest stable release; pin a version tag for deployments. +Keep `/data` on a persistent volume: it holds the memories, the generated secret (`docker exec agentmemory cat /data/secret`) and the worker cache. The container fetches the pinned `state` and `http` registry workers on first start, so it needs network access then. Set `AGENTMEMORY_SECRET`, `EMBEDDING_PROVIDER` and the other variables from the sections above with `-e`. The `latest` tag points at the image for the release GitHub marks as Latest, so an older or prerelease build never replaces it. Pin a version tag for deployments. ## Local embeddings From 84b6cd8069306915112727200cd6d33b47b81e50 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 15:59:46 +0530 Subject: [PATCH 3/4] ci: pick latest by semver across stable releases The latest job now takes the highest stable release version from all non-draft, non-prerelease releases instead of the release GitHub marks as Latest, which a backport published later would become. --- .github/workflows/docker-image.yml | 12 ++++++++++-- deploy/README.md | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 539e0378d4..fc5a62b3a3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -192,8 +192,16 @@ jobs: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} run: | - tag=$(gh api "repos/$REPO/releases/latest" --jq .tag_name) - newest="${tag#v}" + newest=$(gh api --paginate "repos/$REPO/releases" \ + --jq '.[] | select(.draft | not) | select(.prerelease | not) | .tag_name' \ + | sed 's/^v//' \ + | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \ + | sort -t. -k1,1n -k2,2n -k3,3n \ + | tail -n 1) + if [ -z "$newest" ]; then + echo "No stable release found; leaving latest unchanged." + exit 0 + fi if ! skopeo inspect --raw "docker://$IMAGE:$newest" >/dev/null 2>&1; then echo "Image for the newest stable release ($newest) is not pushed yet; leaving latest unchanged." exit 0 diff --git a/deploy/README.md b/deploy/README.md index 048cca94d5..7f6d503d3a 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -36,7 +36,7 @@ docker run -d --name agentmemory \ ghumarerohit/agentmemory: ``` -Keep `/data` on a persistent volume: it holds the memories, the generated secret (`docker exec agentmemory cat /data/secret`) and the worker cache. The container fetches the pinned `state` and `http` registry workers on first start, so it needs network access then. Set `AGENTMEMORY_SECRET`, `EMBEDDING_PROVIDER` and the other variables from the sections above with `-e`. The `latest` tag points at the image for the release GitHub marks as Latest, so an older or prerelease build never replaces it. Pin a version tag for deployments. +Keep `/data` on a persistent volume: it holds the memories, the generated secret (`docker exec agentmemory cat /data/secret`) and the worker cache. The container fetches the pinned `state` and `http` registry workers on first start, so it needs network access then. Set `AGENTMEMORY_SECRET`, `EMBEDDING_PROVIDER` and the other variables from the sections above with `-e`. The `latest` tag points at the image for the highest stable release version (semver order, prereleases and drafts excluded), so an older, backported or prerelease build never replaces it. Pin a version tag for deployments. ## Local embeddings From 97465fad4002a1ebfa54666921bd604a744089e7 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 16:33:20 +0530 Subject: [PATCH 4/4] ci: harden the Docker image workflow from review - Check out the release tag exactly as published; only a manual run maps the version to v. - Reject versions longer than the 128-character Docker tag limit. - Keep the image artifact for 14 days so a slow environment approval does not expire it. - Treat no stable release as a clean no-op under pipefail. --- .github/workflows/docker-image.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fc5a62b3a3..840601edfc 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -33,17 +33,23 @@ jobs: INPUT_VERSION: ${{ inputs.version }} run: | if [ "$EVENT" = "release" ]; then + tag="$RELEASE_TAG" version="${RELEASE_TAG#v}" else version="${INPUT_VERSION#v}" + tag="v$version" fi if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then echo "Not a release version: $version" >&2 exit 1 fi + if [ "${#version}" -gt 128 ]; then + echo "Version is longer than the 128-character Docker tag limit: $version" >&2 + exit 1 + fi { echo "version=$version" - echo "tag=v$version" + echo "tag=$tag" } >> "$GITHUB_OUTPUT" - uses: actions/checkout@v6 @@ -115,7 +121,7 @@ jobs: with: name: agentmemory-image-${{ steps.v.outputs.version }} path: ${{ runner.temp }}/image.tar - retention-days: 1 + retention-days: 14 if-no-files-found: error publish: @@ -192,10 +198,11 @@ jobs: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} run: | - newest=$(gh api --paginate "repos/$REPO/releases" \ - --jq '.[] | select(.draft | not) | select(.prerelease | not) | .tag_name' \ + tags=$(gh api --paginate "repos/$REPO/releases" \ + --jq '.[] | select(.draft | not) | select(.prerelease | not) | .tag_name') + newest=$(printf '%s\n' "$tags" \ | sed 's/^v//' \ - | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \ + | { grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' || true; } \ | sort -t. -k1,1n -k2,2n -k3,3n \ | tail -n 1) if [ -z "$newest" ]; then