π OpenHands: AI-Driven Development
feat: Tag images instead of rebuilding on git tags; stop publishing v0 runtime image (#14005)
Joe Lavertyb43d9b1929e3
diff --git a/.agents/skills/update-sdk/SKILL.md b/.agents/skills/update-sdk/SKILL.mdindex a818db3641..cf8a1ad0ec 100644--- a/.agents/skills/update-sdk/SKILL.md+++ b/.agents/skills/update-sdk/SKILL.md@@ -95,13 +95,13 @@ git tag X.Y.ZCreate a `saas-rel-X.Y.Z` branch from the tagged commit for the SaaS deployment pipeline.-#### Step 3: CI builds Docker images automatically+#### Step 3: Images get tagged automatically-The `ghcr-build.yml` workflow triggers on tag pushes and produces:-- `ghcr.io/openhands/openhands:X.Y.Z`, `X.Y`, `X`, `latest`-- `ghcr.io/openhands/runtime:X.Y.Z-nikolaik`, `X.Y-nikolaik`+Every push to `main` / `saas-rel-*` / `oss-rel-*` builds and publishes `ghcr.io/openhands/openhands` and `ghcr.io/openhands/enterprise-server` images for that commit (tagged by SHA, short SHA, and branch name).-The tagging logic lives in `containers/build.sh` β when `GITHUB_REF_NAME` matches a semver pattern (`^[0-9]+\.[0-9]+\.[0-9]+$`), it auto-generates major, major.minor, and `latest` tags.+Pushing a git tag `X.Y.Z` then tags the images for that commit with `X.Y.Z`, `X.Y`, `X`, and `latest`. Non-semver tags just get their literal name applied.++Requires the commit to already be built. If you push the tag too early, the retag CI job fails loudly β re-run it from the Actions UI once the build completes.## Development: Pin SDK to an Unreleased Commitdiff --git a/.agents/skills/update-sdk/references/docker-image-locations.md b/.agents/skills/update-sdk/references/docker-image-locations.mdindex c7a23bf43c..3fb466ba01 100644--- a/.agents/skills/update-sdk/references/docker-image-locations.md+++ b/.agents/skills/update-sdk/references/docker-image-locations.md@@ -80,5 +80,4 @@ These reference the V0 runtime image (`ghcr.io/openhands/runtime:X.Y-nikolaik`)|----------|-------|| `ghcr.io/openhands/agent-server` | V1 agent-server (sandbox) β built by SDK repo CI || `ghcr.io/openhands/openhands` | Main app image β built by `ghcr-build.yml` |-| `ghcr.io/openhands/runtime` | V0 runtime sandbox β built by `ghcr-build.yml` || `docker.openhands.dev/openhands/*` | Mirror/CDN for the above images |diff --git a/.github/actions/docker-image-tags/action.yml b/.github/actions/docker-image-tags/action.ymlnew file mode 100644index 0000000000..e54a4d04e8--- /dev/null+++ b/.github/actions/docker-image-tags/action.yml@@ -0,0 +1,51 @@+name: Compute Docker image tags+description: Produce the canonical OpenHands Docker tag set (ref name, short SHA, full SHA β each in bare and `sha-` prefixed form) for a given image, with optional suffix and extra raw tags.++inputs:+ image:+ description: Fully qualified image name (e.g. ghcr.io/owner/openhands).+ required: true+ ref-name:+ description: Git ref name to emit as a tag (e.g. main, pr-123, saas-rel-1.2.3).+ required: true+ suffix:+ description: Suffix appended to every tag (e.g. -amd64, -nikolaik-arm64). Leave empty for base (multi-arch manifest) tags.+ required: false+ default: ""+ extra-tags:+ description: Additional newline-separated metadata-action tag rules (e.g. extra `type=raw,value=...` lines).+ required: false+ default: ""++outputs:+ tags:+ description: Newline-separated list of fully qualified image tags.+ value: ${{ steps.meta.outputs.tags }}+ labels:+ description: Image labels emitted by docker/metadata-action.+ value: ${{ steps.meta.outputs.labels }}+ version:+ description: Sanitized version string (ref-name with any suffix applied). Safe to use in docker tags.+ value: ${{ steps.meta.outputs.version }}++runs:+ using: composite+ steps:+ - name: Compute tags+ id: meta+ uses: docker/metadata-action@v6+ env:+ # Use the PR head SHA (not the merge SHA) for sha-prefixed tags.+ DOCKER_METADATA_PR_HEAD_SHA: "true"+ with:+ images: ${{ inputs.image }}+ flavor: |+ latest=false+ suffix=${{ inputs.suffix }}+ tags: |+ type=raw,value=${{ inputs.ref-name }}+ type=sha,prefix=sha-+ type=sha,prefix=+ type=sha,format=long,prefix=sha-+ type=sha,format=long,prefix=+ ${{ inputs.extra-tags }}diff --git a/.github/actions/docker-merge-manifest/action.yml b/.github/actions/docker-merge-manifest/action.ymlnew file mode 100644index 0000000000..4c1d89183d--- /dev/null+++ b/.github/actions/docker-merge-manifest/action.yml@@ -0,0 +1,43 @@+name: Merge multi-arch Docker manifest+description: Build a multi-arch manifest from per-arch image tags pushed by an earlier build step.++inputs:+ base-tags:+ description: Newline-separated list of base tags (without architecture suffix).+ required: true+ archs:+ description: Space-separated list of architectures (e.g. "amd64 arm64").+ required: true++runs:+ using: composite+ steps:+ - name: Login to GHCR+ uses: docker/login-action@v4+ with:+ registry: ghcr.io+ username: ${{ github.repository_owner }}+ password: ${{ github.token }}++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3++ - name: Create multi-arch manifests+ shell: bash+ env:+ BASE_TAGS: ${{ inputs.base-tags }}+ ARCHS: ${{ inputs.archs }}+ run: |+ while IFS= read -r tag; do+ [[ -z "$tag" ]] && continue+ sources=""+ for arch in $ARCHS; do+ if ! docker buildx imagetools inspect "${tag}-${arch}" > /dev/null 2>&1; then+ echo "::error::Missing image ${tag}-${arch}"+ exit 1+ fi+ sources+=" ${tag}-${arch}"+ done+ echo "Creating manifest for $tag from:$sources"+ docker buildx imagetools create -t "$tag" $sources+ done <<< "$BASE_TAGS"diff --git a/.github/scripts/update_pr_description.sh b/.github/scripts/update_pr_description.shindex fd8b640c74..119a54a2a8 100755--- a/.github/scripts/update_pr_description.sh+++ b/.github/scripts/update_pr_description.sh@@ -13,7 +13,6 @@ DOCKER_RUN_COMMAND="docker run -it --rm \-p 3000:3000 \-v /var/run/docker.sock:/var/run/docker.sock \--add-host host.docker.internal:host-gateway \- -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.openhands.dev/openhands/runtime:${SHORT_SHA}-nikolaik \--name openhands-app-${SHORT_SHA} \docker.openhands.dev/openhands/openhands:${SHORT_SHA}"diff --git a/.github/workflows/_build-image.yml b/.github/workflows/_build-image.ymlnew file mode 100644index 0000000000..efbf5f1eef--- /dev/null+++ b/.github/workflows/_build-image.yml@@ -0,0 +1,116 @@+# Reusable workflow: build a multi-arch Docker image and publish a merged manifest.+# Called per image from .github/workflows/ghcr-build.yml.+name: Build and push multi-arch image++on:+ workflow_call:+ inputs:+ image:+ description: Fully-qualified image name (e.g. "ghcr.io/all-hands-ai/openhands").+ required: true+ type: string+ context:+ description: Docker build context.+ required: false+ type: string+ default: "."+ dockerfile:+ description: Path to the Dockerfile.+ required: true+ type: string+ extra-build-args:+ description: Additional build-args (newline-separated). OPENHANDS_BUILD_VERSION is added automatically.+ required: false+ type: string+ default: ""+ provenance:+ description: Value passed to docker/build-push-action provenance.+ required: false+ type: boolean+ default: false+ sbom:+ description: Value passed to docker/build-push-action sbom.+ required: false+ type: boolean+ default: false+ buildx-driver-opts:+ description: Extra buildx driver-opts (e.g. "network=host" for enterprise).+ required: false+ type: string+ default: ""++env:+ RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}+ RELEVANT_REF_NAME: ${{ github.event.pull_request.number && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}++jobs:+ build:+ name: Build ${{ inputs.image }} (${{ matrix.arch }})+ runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-22.04' }}+ permissions:+ contents: read+ packages: write+ strategy:+ matrix:+ arch: [amd64, arm64]+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ with:+ ref: ${{ github.event.pull_request.head.sha }}+ - name: Login to GHCR+ uses: docker/login-action@v4+ with:+ registry: ghcr.io+ username: ${{ github.repository_owner }}+ password: ${{ secrets.GITHUB_TOKEN }}+ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3+ with:+ driver-opts: ${{ inputs.buildx-driver-opts }}+ - name: Compute per-arch tags+ id: meta+ uses: ./.github/actions/docker-image-tags+ with:+ image: ${{ inputs.image }}+ ref-name: ${{ env.RELEVANT_REF_NAME }}+ suffix: -${{ matrix.arch }}+ - name: Build and push+ uses: docker/build-push-action@v7+ with:+ context: ${{ inputs.context }}+ file: ${{ inputs.dockerfile }}+ push: true+ tags: ${{ steps.meta.outputs.tags }}+ labels: ${{ steps.meta.outputs.labels }}+ platforms: linux/${{ matrix.arch }}+ build-args: |+ OPENHANDS_BUILD_VERSION=${{ env.RELEVANT_REF_NAME }}+ ${{ inputs.extra-build-args }}+ cache-from: |+ type=registry,ref=${{ inputs.image }}:buildcache-${{ steps.meta.outputs.version }}+ type=registry,ref=${{ inputs.image }}:buildcache-main-${{ matrix.arch }}+ cache-to: type=registry,ref=${{ inputs.image }}:buildcache-${{ steps.meta.outputs.version }},mode=max+ provenance: ${{ inputs.provenance }}+ sbom: ${{ inputs.sbom }}++ merge:+ name: Merge ${{ inputs.image }} manifest+ runs-on: ubuntu-22.04+ needs: build+ permissions:+ packages: write+ steps:+ - name: Checkout+ uses: actions/checkout@v6+ - name: Compute base tags+ id: meta_base+ uses: ./.github/actions/docker-image-tags+ with:+ image: ${{ inputs.image }}+ ref-name: ${{ env.RELEVANT_REF_NAME }}+ - name: Merge manifests+ uses: ./.github/actions/docker-merge-manifest+ with:+ base-tags: ${{ steps.meta_base.outputs.tags }}+ archs: "amd64 arm64"diff --git a/.github/workflows/ghcr-build.yml b/.github/workflows/ghcr-build.ymlindex 1a36885c7f..0bff67076a 100644--- a/.github/workflows/ghcr-build.yml+++ b/.github/workflows/ghcr-build.yml@@ -1,17 +1,13 @@-# Workflow that builds, tests and then pushes the OpenHands and runtime docker images to the ghcr.io repository+# Workflow that builds and pushes the OpenHands app and enterprise Docker images to ghcr.io.+# Per-image build logic lives in .github/workflows/_build-image.yml.name: Docker-# Always run on "main"-# Always run on tags-# Always run on PRs-# Can also be triggered manuallyon:push:branches:- main- "saas-rel-*"- tags:- - "*"+ - "oss-rel-*"pull_request:workflow_dispatch:inputs:@@ -20,401 +16,37 @@ on:required: truedefault: ""-# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique group+# PR events share a group so pushes supersede each other; each commit on a release branch gets its own group.concurrency:group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }}cancel-in-progress: true-env:- RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-jobs:- define-matrix:- runs-on: ubuntu-latest- outputs:- base_image: ${{ steps.define-base-images.outputs.base_image }}- architectures: ${{ steps.define-base-images.outputs.architectures }}- steps:- - name: Define base images- shell: bash- id: define-base-images- run: |- architectures='["amd64", "arm64"]'- if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then- json=$(jq -n -c '[- { image: "nikolaik/python-nodejs:python3.12-nodejs22-slim", tag: "nikolaik" }- ]')- else- json=$(jq -n -c '[- { image: "nikolaik/python-nodejs:python3.12-nodejs22-slim", tag: "nikolaik" },- { image: "ubuntu:24.04", tag: "ubuntu" }- ]')- fi- echo "base_image=$json" >> "$GITHUB_OUTPUT"- echo "architectures=$architectures" >> "$GITHUB_OUTPUT"-- # Builds the OpenHands Docker images (one per architecture, natively)- ghcr_build_app:- name: Build App Image (${{ matrix.arch }})- runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-22.04' }}- if: "!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/ext-v'))"- needs: define-matrix- outputs:- # All arch variants produce the same base tags, so any entry works- base_tags: ${{ steps.build.outputs.base_tags }}- permissions:- contents: read- packages: write- strategy:- matrix:- arch: ${{ fromJson(needs.define-matrix.outputs.architectures) }}- steps:- - name: Checkout- uses: actions/checkout@v6- with:- ref: ${{ github.event.pull_request.head.sha }}- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}- - name: Set up Docker Buildx- id: buildx- uses: docker/setup-buildx-action@v3- - name: Lowercase Repository Owner- run: |- echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- - name: Build and push app image- id: build- if: "!github.event.pull_request.head.repo.fork"- run: |- ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --push --arch ${{ matrix.arch }}-- # Output base tags (without arch suffix) for the merge job- ./containers/build.sh -i openhands -o ${{ env.REPO_OWNER }} --arch ${{ matrix.arch }} --dry- BASE_TAGS=$(jq -r '.base_tags | join("\n")' docker-build-dry.json)- echo "base_tags<<EOF" >> "$GITHUB_OUTPUT"- echo "$BASE_TAGS" >> "$GITHUB_OUTPUT"- echo "EOF" >> "$GITHUB_OUTPUT"-- # Merges per-architecture app images into a multi-arch manifest- ghcr_build_app_merge:- name: Merge App Multi-Arch Manifest- runs-on: ubuntu-22.04- needs: [define-matrix, ghcr_build_app]+ build_app:+ name: Appif: github.event.pull_request.head.repo.fork != true- permissions:- packages: write- steps:- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3- - name: Merge multi-arch manifest- run: |- ARCHS='${{ join(fromJson(needs.define-matrix.outputs.architectures), ' ') }}'- TAGS="${{ needs.ghcr_build_app.outputs.base_tags }}"- while IFS= read -r tag; do- [[ -z "$tag" ]] && continue- sources=""- for arch in $ARCHS; do- if ! docker buildx imagetools inspect "${tag}-${arch}" > /dev/null 2>&1; then- echo "::error::Missing image ${tag}-${arch}"- exit 1- fi- sources+=" ${tag}-${arch}"- done- echo "Creating manifest for $tag from:$sources"- docker buildx imagetools create -t "$tag" $sources- done <<< "$TAGS"+ uses: ./.github/workflows/_build-image.yml+ with:+ image: ghcr.io/openhands/openhands+ dockerfile: containers/app/Dockerfile- # Builds the runtime Docker images (one per architecture x base_image, natively)- ghcr_build_runtime:- name: Build Runtime Image (${{ matrix.base_image.tag }}, ${{ matrix.arch }})- runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-22.04' }}- if: "!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/ext-v'))"- permissions:- contents: read- packages: write- needs: define-matrix- outputs:- # Keyed by base_image tag so the merge job can access per-variant tags.- # Matrix outputs from different entries with the same key overwrite each other,- # but all arch variants of the same base_image produce identical base tags.- base_tags_nikolaik: ${{ steps.params.outputs.base_tags_nikolaik }}- base_tags_ubuntu: ${{ steps.params.outputs.base_tags_ubuntu }}- strategy:- matrix:- base_image: ${{ fromJson(needs.define-matrix.outputs.base_image) }}- arch: ${{ fromJson(needs.define-matrix.outputs.architectures) }}- steps:- - name: Checkout- uses: actions/checkout@v6- with:- ref: ${{ github.event.pull_request.head.sha }}- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}- - name: Set up Docker Buildx- id: buildx- uses: docker/setup-buildx-action@v3- - name: Install poetry via pipx- run: pipx install poetry- - name: Set up Python- uses: actions/setup-python@v5- with:- python-version: "3.12"- cache: poetry- - name: Install Python dependencies using Poetry- run: make install-python-dependencies POETRY_GROUP=main INSTALL_PLAYWRIGHT=0- - name: Create source distribution and Dockerfile- run: poetry run python3 -m openhands.runtime.utils.runtime_build --base_image ${{ matrix.base_image.image }} --build_folder containers/runtime --force_rebuild- - name: Lowercase Repository Owner- run: |- echo REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV- - name: Short SHA- run: |- echo SHORT_SHA=$(git rev-parse --short "$RELEVANT_SHA") >> $GITHUB_ENV- - name: Determine docker build params- id: params- if: github.event.pull_request.head.repo.fork != true- shell: bash- run: |- ./containers/build.sh -i runtime -o ${{ env.REPO_OWNER }} -t ${{ matrix.base_image.tag }} --arch ${{ matrix.arch }} --dry-- DOCKER_BUILD_JSON=$(jq -c . < docker-build-dry.json)- echo "DOCKER_TAGS=$(echo "$DOCKER_BUILD_JSON" | jq -r '.tags | join(",")')" >> $GITHUB_ENV- echo "DOCKER_PLATFORM=$(echo "$DOCKER_BUILD_JSON" | jq -r '.platform')" >> $GITHUB_ENV- echo "DOCKER_BUILD_ARGS=$(echo "$DOCKER_BUILD_JSON" | jq -r '.build_args | join(",")')" >> $GITHUB_ENV-- # Output base tags (without arch suffix) keyed by base_image tag for the merge job- BASE_TAGS=$(echo "$DOCKER_BUILD_JSON" | jq -r '.base_tags | join("\n")')- echo "base_tags_${{ matrix.base_image.tag }}<<EOF" >> "$GITHUB_OUTPUT"- echo "$BASE_TAGS" >> "$GITHUB_OUTPUT"- echo "EOF" >> "$GITHUB_OUTPUT"- - name: Build and push runtime image ${{ matrix.base_image.image }}- if: github.event.pull_request.head.repo.fork != true- uses: docker/build-push-action@v7- with:- push: true- tags: ${{ env.DOCKER_TAGS }}- platforms: ${{ env.DOCKER_PLATFORM }}- cache-from: type=registry,ref=ghcr.io/${{ env.REPO_OWNER }}/runtime:buildcache-${{ matrix.base_image.tag }}-${{ matrix.arch }}- cache-to: type=registry,ref=ghcr.io/${{ env.REPO_OWNER }}/runtime:buildcache-${{ matrix.base_image.tag }}-${{ matrix.arch }},mode=max- build-args: ${{ env.DOCKER_BUILD_ARGS }}- context: containers/runtime- provenance: false- # Forked repos can't push to GHCR, so we just build in order to populate the cache for rebuilding- - name: Build runtime image ${{ matrix.base_image.image }} for fork- if: github.event.pull_request.head.repo.fork- uses: docker/build-push-action@v7- with:- tags: ghcr.io/${{ env.REPO_OWNER }}/runtime:${{ env.RELEVANT_SHA }}-${{ matrix.base_image.tag }}- context: containers/runtime- - name: Upload runtime source for fork- if: github.event.pull_request.head.repo.fork- uses: actions/upload-artifact@v7- with:- name: runtime-src-${{ matrix.base_image.tag }}-${{ matrix.arch }}- path: containers/runtime-- # Merges per-architecture runtime images into multi-arch manifests- ghcr_build_runtime_merge:- name: Merge Runtime Multi-Arch Manifest- runs-on: ubuntu-22.04- needs: [define-matrix, ghcr_build_runtime]+ build_enterprise:+ name: Enterpriseif: github.event.pull_request.head.repo.fork != true- permissions:- packages: write- steps:- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3- - name: Merge multi-arch manifests- run: |- ARCHS='${{ join(fromJson(needs.define-matrix.outputs.architectures), ' ') }}'-- # Merge all runtime base_image variants- for variant_tags in \- "${{ needs.ghcr_build_runtime.outputs.base_tags_nikolaik }}" \- "${{ needs.ghcr_build_runtime.outputs.base_tags_ubuntu }}"; do- while IFS= read -r tag; do- [[ -z "$tag" ]] && continue- sources=""- for arch in $ARCHS; do- if ! docker buildx imagetools inspect "${tag}-${arch}" > /dev/null 2>&1; then- echo "::error::Missing image ${tag}-${arch}"- exit 1- fi- sources+=" ${tag}-${arch}"- done- echo "Creating manifest for $tag from:$sources"- docker buildx imagetools create -t "$tag" $sources- done <<< "$variant_tags"- done-- ghcr_build_enterprise:- name: Push Enterprise Image (${{ matrix.arch }})- runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-22.04' }}- permissions:- contents: read- packages: write- needs: [define-matrix, ghcr_build_app_merge]- # Do not build enterprise in forks- if: github.event.pull_request.head.repo.fork != true- outputs:- # Tags without arch suffix, for the merge job- base_tags: ${{ steps.meta_base.outputs.tags }}- strategy:- matrix:- arch: ${{ fromJson(needs.define-matrix.outputs.architectures) }}- steps:- - name: Checkout- uses: actions/checkout@v6- with:- ref: ${{ github.event.pull_request.head.sha }}-- # Set up Docker Buildx for better performance- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3- with:- driver-opts: network=host-- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract metadata (tags, labels) for Docker- id: meta- uses: docker/metadata-action@v6- with:- images: ghcr.io/openhands/enterprise-server- tags: |- type=ref,event=branch- type=ref,event=pr- type=sha- type=sha,format=long- type=semver,pattern={{version}}- type=semver,pattern={{major}}.{{minor}}- type=semver,pattern={{major}}- type=match,pattern=cloud-\d+\.\d+\.\d+- flavor: |- latest=auto- prefix=- suffix=-${{ matrix.arch }}- env:- DOCKER_METADATA_PR_HEAD_SHA: true-- # Also compute base tags (no arch suffix) for the merge job output- - name: Extract base metadata for merge- id: meta_base- uses: docker/metadata-action@v6- with:- images: ghcr.io/openhands/enterprise-server- tags: |- type=ref,event=branch- type=ref,event=pr- type=sha- type=sha,format=long- type=semver,pattern={{version}}- type=semver,pattern={{major}}.{{minor}}- type=semver,pattern={{major}}- type=match,pattern=cloud-\d+\.\d+\.\d+- flavor: |- latest=auto- prefix=- suffix=- env:- DOCKER_METADATA_PR_HEAD_SHA: true-- - name: Determine app image tag- shell: bash- run: |- # Use the commit SHA to pin the exact app image built by ghcr_build_app,- # rather than a mutable branch tag like "main" which can serve stale cached layers.- echo "OPENHANDS_DOCKER_TAG=${RELEVANT_SHA}" >> $GITHUB_ENV- - name: Build and push Docker image- uses: docker/build-push-action@v7- with:- context: .- file: enterprise/Dockerfile- push: true- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- build-args: |- OPENHANDS_VERSION=${{ env.OPENHANDS_DOCKER_TAG }}- platforms: linux/${{ matrix.arch }}- # Add build provenance- provenance: true- # Add build attestations for better security- sbom: true-- # Merges per-architecture enterprise images into a multi-arch manifest- ghcr_build_enterprise_merge:- name: Merge Enterprise Multi-Arch Manifest- runs-on: ubuntu-22.04- permissions:- packages: write- needs: [define-matrix, ghcr_build_enterprise]- if: github.event.pull_request.head.repo.fork != true- steps:- - name: Login to GHCR- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.repository_owner }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@v3-- - name: Merge multi-arch manifest- run: |- ARCHS='${{ join(fromJson(needs.define-matrix.outputs.architectures), ' ') }}'- TAGS="${{ needs.ghcr_build_enterprise.outputs.base_tags }}"- while IFS= read -r tag; do- [[ -z "$tag" ]] && continue- sources=""- for arch in $ARCHS; do- if ! docker buildx imagetools inspect "${tag}-${arch}" > /dev/null 2>&1; then- echo "::error::Missing image ${tag}-${arch}"- exit 1- fi- sources+=" ${tag}-${arch}"- done- echo "Creating manifest for $tag from:$sources"- docker buildx imagetools create -t "$tag" $sources- done <<< "$TAGS"-- # "All Runtime Tests Passed" is a required job for PRs to merge- # We can remove this once the config changes- runtime_tests_check_success:- name: All Runtime Tests Passed- runs-on: ubuntu-22.04- steps:- - name: All tests passed- run: echo "All runtime tests have passed successfully!"+ needs: build_app+ uses: ./.github/workflows/_build-image.yml+ with:+ image: ghcr.io/openhands/enterprise-server+ dockerfile: enterprise/Dockerfile+ extra-build-args: OPENHANDS_VERSION=sha-${{ github.event.pull_request.head.sha || github.sha }}+ provenance: true+ sbom: true+ buildx-driver-opts: network=hostupdate_pr_description:name: Update PR Descriptionif: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'- needs: [ghcr_build_runtime_merge]+ needs: build_appruns-on: ubuntu-22.04steps:- name: Checkout@@ -422,7 +54,7 @@ jobs:- name: Get short SHAid: short_sha- run: echo "SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT+ run: echo "SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT"- name: Update PR Descriptionenv:@@ -433,4 +65,4 @@ jobs:shell: bashrun: |echo "Updating PR description with Docker and uvx commands"- bash ${GITHUB_WORKSPACE}/.github/scripts/update_pr_description.sh+ bash "${GITHUB_WORKSPACE}/.github/scripts/update_pr_description.sh"diff --git a/.github/workflows/tag-image.yml b/.github/workflows/tag-image.ymlnew file mode 100644index 0000000000..91f4a19d3a--- /dev/null+++ b/.github/workflows/tag-image.yml@@ -0,0 +1,59 @@+# Adds a git-tag name to existing Docker images.+# Triggered when a tag is pushed: finds the images built at the tag's commit+# (tagged `sha-<full>`) and adds the tag name as an alias for the same manifest.+# Semver tags (X.Y.Z) also get X.Y, X, and latest aliases.+# No rebuild β pure registry-side retag via `docker buildx imagetools create`.+name: Tag Docker images++on:+ push:+ tags:+ - "*"++jobs:+ retag:+ runs-on: ubuntu-22.04+ permissions:+ packages: write+ strategy:+ matrix:+ image:+ - ghcr.io/openhands/openhands+ - ghcr.io/openhands/enterprise-server+ steps:+ - name: Login to GHCR+ uses: docker/login-action@v4+ with:+ registry: ghcr.io+ username: ${{ github.repository_owner }}+ password: ${{ secrets.GITHUB_TOKEN }}+ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@v3+ - name: Compute tags+ id: meta+ uses: docker/metadata-action@v6+ with:+ images: ${{ matrix.image }}+ flavor: latest=auto+ tags: |+ type=ref,event=tag+ type=semver,pattern={{version}}+ type=semver,pattern={{major}}.{{minor}}+ type=semver,pattern={{major}}+ - name: Add tags to existing image+ env:+ SRC: ${{ matrix.image }}:sha-${{ github.sha }}+ TAGS: ${{ steps.meta.outputs.tags }}+ shell: bash+ run: |+ set -euo pipefail+ if ! docker buildx imagetools inspect "$SRC" > /dev/null 2>&1; then+ echo "::error::Source image $SRC does not exist. The Docker workflow for commit ${{ github.sha }} may not have completed successfully. Re-run this workflow once the build finishes."+ exit 1+ fi+ args=()+ while IFS= read -r tag; do+ [[ -z "$tag" ]] && continue+ args+=(-t "$tag")+ done <<< "$TAGS"+ docker buildx imagetools create "${args[@]}" "$SRC"diff --git a/.gitignore b/.gitignoreindex 47512f9d0f..e852c54a97 100644--- a/.gitignore+++ b/.gitignore@@ -254,10 +254,6 @@ run_instance_logsruntime_*.tar-# docker build-containers/runtime/Dockerfile-containers/runtime/project.tar.gz-containers/runtime/code**/node_modules/# test resultsdiff --git a/containers/app/config.sh b/containers/app/config.shdeleted file mode 100644index 41d00c84a0..0000000000--- a/containers/app/config.sh+++ /dev/null@@ -1,4 +0,0 @@-DOCKER_REGISTRY=ghcr.io-DOCKER_ORG=openhands-DOCKER_IMAGE=openhands-DOCKER_BASE_DIR="."diff --git a/containers/build.sh b/containers/build.shdeleted file mode 100755index 79dc59c417..0000000000--- a/containers/build.sh+++ /dev/null@@ -1,208 +0,0 @@-#!/usr/bin/env bash-set -eo pipefail--# Initialize variables with default values-image_name=""-org_name=""-push=0-load=0-tag_suffix=""-dry_run=0-arch_suffix=""--# Function to display usage information-usage() {- echo "Usage: $0 -i <image_name> [-o <org_name>] [--push] [--load] [-t <tag_suffix>] [--dry] [--arch <arch>]"- echo " -i: Image name (required)"- echo " -o: Organization name"- echo " --push: Push the image"- echo " --load: Load the image"- echo " -t: Tag suffix"- echo " --dry: Don't build, only create build-args.json"- echo " --arch: Architecture suffix (e.g. amd64 or arm64). Appends -<arch> to tags and forces single-platform build"- exit 1-}--# Parse command-line options-while [[ $# -gt 0 ]]; do- case $1 in- -i) image_name="$2"; shift 2 ;;- -o) org_name="$2"; shift 2 ;;- --push) push=1; shift ;;- --load) load=1; shift ;;- -t) tag_suffix="$2"; shift 2 ;;- --dry) dry_run=1; shift ;;- --arch) arch_suffix="$2"; shift 2 ;;- *) usage ;;- esac-done-# Check if required arguments are provided-if [[ -z "$image_name" ]]; then- echo "Error: Image name is required."- usage-fi--echo "Building: $image_name"-tags=()--OPENHANDS_BUILD_VERSION="dev"--cache_tag_base="buildcache"-cache_tag="$cache_tag_base"--if [[ -n $RELEVANT_SHA ]]; then- git_hash=$(git rev-parse --short "$RELEVANT_SHA")- tags+=("$git_hash")- tags+=("$RELEVANT_SHA")-fi--if [[ -n $GITHUB_REF_NAME ]]; then- # check if ref name is a version number- if [[ $GITHUB_REF_NAME =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- major_version=$(echo "$GITHUB_REF_NAME" | cut -d. -f1)- minor_version=$(echo "$GITHUB_REF_NAME" | cut -d. -f1,2)- tags+=("$major_version" "$minor_version")- tags+=("latest")- fi- sanitized_ref_name=$(echo "$GITHUB_REF_NAME" | sed 's/[^a-zA-Z0-9.-]\+/-/g')- OPENHANDS_BUILD_VERSION=$sanitized_ref_name- sanitized_ref_name=$(echo "$sanitized_ref_name" | tr '[:upper:]' '[:lower:]') # lower case is required in tagging- tags+=("$sanitized_ref_name")- cache_tag+="-${sanitized_ref_name}"-fi--if [[ -n $tag_suffix ]]; then- cache_tag+="-${tag_suffix}"- for i in "${!tags[@]}"; do- tags[$i]="${tags[$i]}-$tag_suffix"- done-fi--echo "Tags (before arch suffix): ${tags[@]}"--if [[ "$image_name" == "openhands" ]]; then- dir="./containers/app"-elif [[ "$image_name" == "runtime" ]]; then- dir="./containers/runtime"-else- dir="./containers/$image_name"-fi--if [[ (! -f "$dir/Dockerfile") && "$image_name" != "runtime" ]]; then- # Allow runtime to be built without a Dockerfile- echo "No Dockerfile found"- exit 1-fi-if [[ ! -f "$dir/config.sh" ]]; then- echo "No config.sh found for Dockerfile"- exit 1-fi--source "$dir/config.sh"--if [[ -n "$org_name" ]]; then- DOCKER_ORG="$org_name"-fi--# If $DOCKER_IMAGE_SOURCE_TAG is set, add it to the tags-if [[ -n "$DOCKER_IMAGE_SOURCE_TAG" ]]; then- tags+=("$DOCKER_IMAGE_SOURCE_TAG")-fi-# If $DOCKER_IMAGE_TAG is set, add it to the tags-if [[ -n "$DOCKER_IMAGE_TAG" ]]; then- tags+=("$DOCKER_IMAGE_TAG")-fi--# Apply architecture suffix for split-arch builds (after all tags are collected)-if [[ -n "$arch_suffix" ]]; then- cache_tag+="-${arch_suffix}"- for i in "${!tags[@]}"; do- tags[$i]="${tags[$i]}-${arch_suffix}"- done- # Force single-platform build for this architecture- arch_platform="linux/${arch_suffix}"-fi--DOCKER_REPOSITORY="$DOCKER_REGISTRY/$DOCKER_ORG/$DOCKER_IMAGE"-DOCKER_REPOSITORY=${DOCKER_REPOSITORY,,} # lowercase-echo "Repo: $DOCKER_REPOSITORY"-echo "Base dir: $DOCKER_BASE_DIR"-echo "Tags: ${tags[@]}"--args=""-full_tags=()-for tag in "${tags[@]}"; do- args+=" -t $DOCKER_REPOSITORY:$tag"- full_tags+=("$DOCKER_REPOSITORY:$tag")-done--if [[ $push -eq 1 ]]; then- args+=" --push"- args+=" --cache-to=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag,mode=max"-fi--if [[ $load -eq 1 ]]; then- args+=" --load"-fi--echo "Args: $args"--# Determine the platform(s) to build for-if [[ -n "$arch_platform" ]]; then- platform="$arch_platform"-elif [[ $load -eq 1 ]]; then- # When loading, build only for the current platform- platform=$(docker version -f '{{.Server.Os}}/{{.Server.Arch}}')-else- # For push or without load, build for multiple platforms- platform="linux/amd64,linux/arm64"-fi-if [[ $dry_run -eq 1 ]]; then- echo "Dry Run is enabled. Writing build config to docker-build-dry.json"- # Compute base tags (arch suffix stripped) for use by merge jobs- base_tags=()- for ftag in "${full_tags[@]}"; do- if [[ -n "$arch_suffix" ]]; then- base_tags+=("${ftag%-${arch_suffix}}")- else- base_tags+=("$ftag")- fi- done- jq -n \- --argjson tags "$(printf '%s\n' "${full_tags[@]}" | jq -R . | jq -s .)" \- --argjson base_tags "$(printf '%s\n' "${base_tags[@]}" | jq -R . | jq -s .)" \- --arg platform "$platform" \- --arg openhands_build_version "$OPENHANDS_BUILD_VERSION" \- --arg dockerfile "$dir/Dockerfile" \- '{- tags: $tags,- base_tags: $base_tags,- platform: $platform,- build_args: [- "OPENHANDS_BUILD_VERSION=" + $openhands_build_version- ],- dockerfile: $dockerfile- }' > docker-build-dry.json-- exit 0-fi----echo "Building for platform(s): $platform"--docker buildx build \- $args \- --build-arg OPENHANDS_BUILD_VERSION="$OPENHANDS_BUILD_VERSION" \- --cache-from=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag \- --cache-from=type=registry,ref=$DOCKER_REPOSITORY:${cache_tag_base}-main${arch_suffix:+-${arch_suffix}} \- --platform $platform \- --provenance=false \- -f "$dir/Dockerfile" \- "$DOCKER_BASE_DIR"--# If load was requested, print the loaded images-if [[ $load -eq 1 ]]; then- echo "Local images built:"- docker images "$DOCKER_REPOSITORY" --format "{{.Repository}}:{{.Tag}}"-fidiff --git a/containers/runtime/README.md b/containers/runtime/README.mddeleted file mode 100644index 7671c32865..0000000000--- a/containers/runtime/README.md+++ /dev/null@@ -1,12 +0,0 @@-# Dynamically constructed Dockerfile--This folder builds a runtime image (sandbox), which will use a dynamically generated `Dockerfile`-that depends on the `base_image` **AND** a [Python source distribution](https://docs.python.org/3.10/distutils/sourcedist.html) that is based on the current commit of `openhands`.--The following command will generate a `Dockerfile` file for `nikolaik/python-nodejs:python3.12-nodejs22` (the default base image), an updated `config.sh` and the runtime source distribution files/folders into `containers/runtime`:--```bash-poetry run python3 -m openhands.runtime.utils.runtime_build \- --base_image nikolaik/python-nodejs:python3.12-nodejs22 \- --build_folder containers/runtime-```diff --git a/containers/runtime/config.sh b/containers/runtime/config.shdeleted file mode 100644index d0250b6dfe..0000000000--- a/containers/runtime/config.sh+++ /dev/null@@ -1,7 +0,0 @@-DOCKER_REGISTRY=ghcr.io-DOCKER_ORG=openhands-DOCKER_BASE_DIR="./containers/runtime"-DOCKER_IMAGE=runtime-# These variables will be appended by the runtime_build.py script-# DOCKER_IMAGE_TAG=-# DOCKER_IMAGE_SOURCE_TAG=