diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3419068..359fec6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -738,3 +738,63 @@ jobs: - name: Stop production stack if: always() run: docker compose down --volumes --remove-orphans + + docker-arm64: + name: Docker image on ARM64 + runs-on: ubuntu-24.04-arm + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Build the image natively on ARM64 + shell: bash + run: | + test "$(grep -c '^FROM python:' Dockerfile)" -eq 1 + tag="$(sed -n 's|^FROM python:\([^ ]*\).*|\1|p' Dockerfile)" + base="$(.github/scripts/pull-official-image.sh "python:$tag")" + mirror_file="$RUNNER_TEMP/Dockerfile.arm64" + sed "s|^FROM python:$tag|FROM $base|" Dockerfile > "$mirror_file" + docker build --pull=false --file "$mirror_file" --tag agentloop:arm64 . + + - name: Check architecture, version and runtime user + shell: bash + run: | + test "$(docker image inspect --format '{{.Architecture}}' agentloop:arm64)" = arm64 + expected="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" + actual="$(docker run --rm agentloop:arm64 python -c 'import agentloop; print(agentloop.__version__)')" + test "$actual" = "$expected" + docker run --rm agentloop:arm64 sh -c 'test "$(id -u)" -ne 0' + + - name: Start the API and dashboard from the ARM64 image + run: | + docker run --detach --name agentloop-api --publish 127.0.0.1:8000:8000 agentloop:arm64 + docker run --detach --name agentloop-dashboard --publish 127.0.0.1:8501:8501 agentloop:arm64 \ + streamlit run dashboard/app.py --server.address=0.0.0.0 --server.port=8501 --server.headless=true + + - name: Verify API round-trip and dashboard health + shell: bash + run: | + wait_for_url() { + for attempt in $(seq 1 60); do + if curl --fail --silent --show-error "$1" > /dev/null; then + return 0 + fi + sleep 2 + done + echo "$1 did not become ready" >&2 + return 1 + } + wait_for_url http://127.0.0.1:8000/readyz + wait_for_url http://127.0.0.1:8501/_stcore/health + AGENTLOOP_API_URL=http://127.0.0.1:8000 python3 scripts/smoke_api.py + + - name: Show container logs on failure + if: failure() + run: | + docker logs agentloop-api --tail 200 || true + docker logs agentloop-dashboard --tail 200 || true + + - name: Stop containers + if: always() + run: docker rm --force agentloop-api agentloop-dashboard || true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 792b42b..f54dd4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,10 +78,19 @@ jobs: - name: Publish distribution uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 - publish-image: - name: Publish container image + build-image: + name: Build container image (${{ matrix.arch }}) needs: [guard, validate] - runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + include: + - arch: amd64 + runner: ubuntu-latest + - arch: arm64 + runner: ubuntu-24.04-arm + # Each architecture builds natively on its own runner; no emulation. + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write @@ -92,6 +101,8 @@ jobs: - name: Build image from the validated tag shell: bash + env: + ARCH: ${{ matrix.arch }} run: | version="${GITHUB_REF_NAME#v}" image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/agentloop" @@ -103,25 +114,54 @@ jobs: docker build --pull=false --file "$mirror_file" \ --label "org.opencontainers.image.version=$version" \ --label "org.opencontainers.image.revision=$GITHUB_SHA" \ - --tag "$image:$version" --tag "$image:latest" . + --tag "$image:$version-$ARCH" . echo "IMAGE=$image" >> "$GITHUB_ENV" echo "VERSION=$version" >> "$GITHUB_ENV" - name: Check the image runs the released version shell: bash + env: + ARCH: ${{ matrix.arch }} run: | - actual="$(docker run --rm "$IMAGE:$VERSION" python -c 'import agentloop; print(agentloop.__version__)')" + test "$(docker image inspect --format '{{.Architecture}}' "$IMAGE:$VERSION-$ARCH")" = "$ARCH" + actual="$(docker run --rm "$IMAGE:$VERSION-$ARCH" python -c 'import agentloop; print(agentloop.__version__)')" test "$actual" = "$VERSION" - docker run --rm "$IMAGE:$VERSION" sh -c 'test "$(id -u)" -ne 0' + docker run --rm "$IMAGE:$VERSION-$ARCH" sh -c 'test "$(id -u)" -ne 0' + + - name: Push the architecture image + env: + GH_TOKEN: ${{ github.token }} + ARCH: ${{ matrix.arch }} + shell: bash + run: | + printf '%s' "$GH_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin + docker push "$IMAGE:$VERSION-$ARCH" + docker logout ghcr.io - - name: Push to GitHub Container Registry + publish-image: + name: Publish container image + needs: build-image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Publish one tag for both architectures env: GH_TOKEN: ${{ github.token }} shell: bash run: | + version="${GITHUB_REF_NAME#v}" + image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/agentloop" printf '%s' "$GH_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin - docker push "$IMAGE:$VERSION" - docker push "$IMAGE:latest" + docker buildx imagetools create \ + --tag "$image:$version" --tag "$image:latest" \ + "$image:$version-amd64" "$image:$version-arm64" + inspected="$(docker buildx imagetools inspect "$image:$version")" + printf '%s\n' "$inspected" + grep -q 'linux/amd64' <<< "$inspected" + grep -q 'linux/arm64' <<< "$inspected" docker logout ghcr.io publish-github: diff --git a/CHANGELOG.md b/CHANGELOG.md index f49bb19..3dd3782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ trace, study, receipt, API and database schema versions. ## [Unreleased] +### Added + +- The container image is published for `linux/arm64` as well as `linux/amd64` + under the same tag, so ARM cloud servers can run AgentLoop. Each architecture + is built natively, checked, and combined into one multi-architecture tag; CI + builds the ARM64 image and runs the API and dashboard from it. + ## [0.2.7] - 2026-11-20 ### Added diff --git a/docs/CLOUD_DEPLOY.md b/docs/CLOUD_DEPLOY.md index 2cc632b..c4270ca 100644 --- a/docs/CLOUD_DEPLOY.md +++ b/docs/CLOUD_DEPLOY.md @@ -24,7 +24,9 @@ docker pull ghcr.io/dipeshbabu/agentloop:0.2.7 The image runs as a non-root user. Its default command starts the API on port 8000; the dashboard uses the same image with a `streamlit run dashboard/app.py` -command. Images are built for `linux/amd64`. Pin an exact version in +command. From 0.2.8, each tag covers `linux/amd64` and `linux/arm64`, so ARM +servers such as AWS Graviton, Google Axion and Azure Cobalt pull the right image +automatically; 0.2.7 is `linux/amd64` only. Pin an exact version in deployments; `latest` follows the newest release. ## Option 1: one server on any cloud diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 49e51ee..dde902b 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -97,10 +97,12 @@ Recover an interrupted tagged release by explicitly dispatching: gh workflow run release.yml --ref vX.Y.Z ``` -The container image job builds the Dockerfile from the tagged commit, checks that -the image reports the release version and runs as a non-root user, and pushes -`ghcr.io/dipeshbabu/agentloop:X.Y.Z` and `:latest` with the workflow's -`GITHUB_TOKEN`. GitHub creates the package as private on its first push. Once, +The container image jobs build the Dockerfile from the tagged commit natively on +an x86-64 and an ARM64 runner. Each checks that its image has the right +architecture, reports the release version and runs as a non-root user, and pushes +`ghcr.io/dipeshbabu/agentloop:X.Y.Z-amd64` or `-arm64`. A final job combines them +into the multi-architecture `:X.Y.Z` and `:latest` tags with the workflow's +`GITHUB_TOKEN` and checks that both platforms are listed. GitHub creates the package as private on its first push. Once, open the package's settings under the owner's **Packages** tab, connect it to this repository if needed, and set its visibility to public so deployments can pull it without credentials.