An open-source, faster Devin alternative
TypeScript
use gallery
Brian Reardon8deb8cad303e
diff --git a/.github/workflows/build-worker-ami.yml b/.github/workflows/build-worker-ami.ymlindex df678353..fc6fe7e4 100644--- a/.github/workflows/build-worker-ami.yml+++ b/.github/workflows/build-worker-ami.yml@@ -72,23 +72,34 @@ jobs:- name: Build imagerun: |+ # Use run number as patch version for gallery (must be integer)+ PATCH=${{ github.run_number }}+packer build \-var "worker_version=$VERSION" \-var "agent_version=$VERSION" \-var "subscription_id=$AZURE_SUBSCRIPTION_ID" \-var "resource_group=$AZURE_RESOURCE_GROUP" \-var "location=$AZURE_LOCATION" \+ -var "image_version_patch=$PATCH" \deploy/packer/worker-ami.pkr.hcl | tee /tmp/packer-output.txt- # Extract the managed image resource ID from Packer output- IMAGE_ID=$(grep -oP '/subscriptions/[^\s"]+' /tmp/packer-output.txt | tail -1)- if [ -z "$IMAGE_ID" ]; then- echo "ERROR: Could not extract image ID from Packer output. Build may have failed."+ # Use the gallery image ID (NVMe-compatible for v6 VMs)+ GALLERY_IMAGE_ID="/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${AZURE_RESOURCE_GROUP}/providers/Microsoft.Compute/galleries/opensandbox_gallery/images/osb-worker/versions/1.0.${PATCH}"++ # Verify it exists+ if ! az sig image-version show \+ --resource-group "$AZURE_RESOURCE_GROUP" \+ --gallery-name opensandbox_gallery \+ --gallery-image-definition osb-worker \+ --gallery-image-version "1.0.${PATCH}" -o none 2>/dev/null; then+ echo "ERROR: Gallery image version 1.0.${PATCH} not found after build"cat /tmp/packer-output.txtexit 1fi- echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV- echo "Built image: $IMAGE_ID"++ echo "IMAGE_ID=$GALLERY_IMAGE_ID" >> $GITHUB_ENV+ echo "Built gallery image: $GALLERY_IMAGE_ID (version=1.0.${PATCH})"- name: Azure Re-Loginuses: azure/login@v2diff --git a/deploy/packer/worker-ami.pkr.hcl b/deploy/packer/worker-ami.pkr.hclindex fe5d3065..be7acdfe 100644--- a/deploy/packer/worker-ami.pkr.hcl+++ b/deploy/packer/worker-ami.pkr.hcl@@ -66,6 +66,18 @@ variable "image_name_prefix" {default = "opensandbox-worker"}+variable "gallery_name" {+ type = string+ default = "opensandbox_gallery"+ description = "Azure Compute Gallery name for NVMe-compatible images."+}++variable "image_version_patch" {+ type = string+ default = "0"+ description = "Patch version for gallery image (integer). Set by CI to a unique number."+}+variable "worker_binary" {type = stringdefault = "bin/opensandbox-worker"@@ -98,10 +110,20 @@ source "azure-arm" "worker" {vm_size = var.vm_sizessh_username = "packer"- # Output: Managed Image in the specified resource group+ # Output: Managed Image (required as intermediate for gallery publish)managed_image_name = "${var.image_name_prefix}-${var.worker_version}"managed_image_resource_group_name = var.resource_group+ # Also publish to Azure Compute Gallery for NVMe/v6 VM compatibility+ shared_image_gallery_destination {+ subscription = var.subscription_id+ resource_group = var.resource_group+ gallery_name = var.gallery_name+ image_name = "osb-worker"+ image_version = "1.0.${var.image_version_patch}"+ replication_regions = [var.location]+ }+azure_tags = {"opensandbox-role" = "worker""opensandbox-version" = var.worker_version