Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

chore(eve): containers - move publishing to VCR (#2888)

Andrew Barbafc58fd1b2b69
diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml
deleted file mode 100644
index f1538371b..000000000
--- a/.github/workflows/container.yml
+++ /dev/null
@@ -1,182 +0,0 @@
-name: Container Image
-
-on:
- push:
- branches: [main]
- tags: ["v*"]
- paths:
- - Dockerfile
- - .dockerignore
- - .github/workflows/container.yml
- pull_request:
- branches: [main]
- paths:
- - Dockerfile
- - .dockerignore
- - .github/workflows/container.yml
- workflow_dispatch:
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: false
-
-env:
- GHCR_REGISTRY: ghcr.io
- GHCR_IMAGE_NAME: vercel/eve
- VCR_REGISTRY: vcr.vercel.com
- VCR_PROJECT_SLUG: eve-e2e
- VCR_REPOSITORY: eve
- VCR_TEAM_SLUG: curated-tests
-
-jobs:
- build:
- runs-on: ubuntu-latest
- permissions:
- contents: read
- packages: write
-
- steps:
- - name: Checkout code
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
-
- - name: Log in to GitHub Container Registry
- if: github.event_name != 'pull_request'
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
- with:
- registry: ${{ env.GHCR_REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Extract Docker metadata
- id: meta
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
- with:
- images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
- tags: |
- type=raw,value=latest,enable={{is_default_branch}}
- type=ref,event=branch
- type=ref,event=pr
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- type=sha,prefix=sha-
-
- - name: Build image for GitHub Container Registry
- uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
- with:
- context: .
- file: ./Dockerfile
- platforms: linux/amd64,linux/arm64
- push: ${{ github.event_name != 'pull_request' }}
- tags: ${{ steps.meta.outputs.tags }}
- labels: |
- org.opencontainers.image.title=eve Sandbox
- org.opencontainers.image.description=Sandbox base image for eve agents.
- org.opencontainers.image.source=https://github.com/vercel/eve
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Setup pnpm
- if: github.event_name != 'pull_request'
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
-
- - name: Setup Node.js
- if: github.event_name != 'pull_request'
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version-file: .nvmrc
- package-manager-cache: false
-
- - name: Validate VCR configuration
- if: github.event_name != 'pull_request'
- env:
- VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- run: |
- missing=0
- for name in VERCEL_TOKEN; do
- if [ -z "${!name}" ]; then
- echo "::error::${name} must be configured to publish to VCR."
- missing=1
- fi
- done
- exit "$missing"
-
- - name: Link Vercel project and pull OIDC token
- if: github.event_name != 'pull_request'
- env:
- VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- run: |
- set -euo pipefail
-
- pnpm dlx [email protected] link --yes --project "$VCR_PROJECT_SLUG" --team "$VCR_TEAM_SLUG" --token "$VERCEL_TOKEN"
- pnpm dlx [email protected] env pull --yes --environment=preview --token "$VERCEL_TOKEN"
-
- oidc_token="$(node -e '
- const fs = require("node:fs");
- const env = fs.readFileSync(".env.local", "utf8");
-
- for (const line of env.split(/\r?\n/)) {
- const match = line.match(/^\s*(?:export\s+)?VERCEL_OIDC_TOKEN\s*=\s*(.*)\s*$/);
- if (!match) continue;
-
- let value = match[1].trim();
- if (
- (value.startsWith("\"") && value.endsWith("\"")) ||
- (value.startsWith("\047") && value.endsWith("\047"))
- ) {
- value = value.slice(1, -1);
- }
-
- process.stdout.write(value);
- process.exit(0);
- }
-
- process.exit(1);
- ')"
-
- if [ -z "$oidc_token" ]; then
- echo "::error::VERCEL_OIDC_TOKEN was not found in .env.local after pulling Vercel env."
- exit 1
- fi
-
- echo "::add-mask::$oidc_token"
- {
- echo "VERCEL_OIDC_TOKEN<<EOF"
- echo "$oidc_token"
- echo "EOF"
- } >>"$GITHUB_ENV"
-
- - name: Log in to Vercel Container Registry
- if: github.event_name != 'pull_request'
- run: docker login vcr.vercel.com --username oidc --password "$VERCEL_OIDC_TOKEN"
-
- - name: Prepare VCR tags
- if: github.event_name != 'pull_request'
- id: vcr-tags
- run: |
- image="${VCR_REGISTRY}/${VCR_TEAM_SLUG}/${VCR_PROJECT_SLUG}/${VCR_REPOSITORY}"
- printf '%s\n' "${image}:latest" >"${RUNNER_TEMP}/vcr-tags"
- {
- echo "tags<<EOF"
- cat "${RUNNER_TEMP}/vcr-tags"
- echo "EOF"
- } >>"$GITHUB_OUTPUT"
-
- - name: Build and publish image to Vercel Container Registry
- if: github.event_name != 'pull_request'
- env:
- VCR_TAGS: ${{ steps.vcr-tags.outputs.tags }}
- run: |
- outputs=()
- while IFS= read -r tag; do
- outputs+=("--output" "type=image,name=${tag},push=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true")
- done <<<"$VCR_TAGS"
-
- docker buildx build --platform linux/amd64 "${outputs[@]}" .
diff --git a/.github/workflows/docker-image-size-analysis.yml b/.github/workflows/docker-image-size-analysis.yml
index cab455ad0..6992ca181 100644
--- a/.github/workflows/docker-image-size-analysis.yml
+++ b/.github/workflows/docker-image-size-analysis.yml
@@ -8,8 +8,8 @@ on:
- reopened
- synchronize
paths:
- - Dockerfile
- - .dockerignore
+ - packages/eve/Dockerfile
+ - packages/eve/.dockerignore
- .github/workflows/docker-image-size-analysis.yml
- scripts/docker-image-size-budget.mjs
- scripts/docker-image-size-report.mjs
@@ -57,12 +57,23 @@ jobs:
id: baseline_image
working-directory: ${{ steps.baseline.outputs.root }}
run: |
+ if [[ -f packages/eve/Dockerfile ]]; then
+ dockerfile=packages/eve/Dockerfile
+ context=packages/eve
+ else
+ # The fallback lets the relocation PR compare against the previous
+ # root-level image definition. Future baselines use the package path.
+ dockerfile=Dockerfile
+ context=.
+ fi
+
docker buildx build \
--cache-from type=gha,scope=eve-docker-image-size \
+ --file "$dockerfile" \
--load \
--platform linux/amd64 \
--tag eve-docker-size:baseline \
- .
+ "$context"
size_bytes="$(docker image inspect eve-docker-size:baseline --format '{{.Size}}')"
echo "size_bytes=$size_bytes" >> "$GITHUB_OUTPUT"
@@ -73,10 +84,11 @@ jobs:
docker buildx build \
--cache-from type=gha,scope=eve-docker-image-size \
--cache-to type=gha,mode=max,scope=eve-docker-image-size \
+ --file packages/eve/Dockerfile \
--load \
--platform linux/amd64 \
--tag eve-docker-size:current \
- .
+ packages/eve
size_bytes="$(docker image inspect eve-docker-size:current --format '{{.Size}}')"
echo "size_bytes=$size_bytes" >> "$GITHUB_OUTPUT"
@@ -106,7 +118,7 @@ jobs:
--baseline-size-bytes "$BASELINE_SIZE_BYTES" \
--current-label "pull request (${HEAD_SHA:0:7})" \
--current-size-bytes "$CURRENT_SIZE_BYTES" \
- --image-label Dockerfile \
+ --image-label packages/eve/Dockerfile \
--output-json "$REPORT_JSON" \
--output-markdown "$REPORT_MARKDOWN"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 878fe386d..b02e16f04 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -11,6 +11,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
+env:
+ VCR_IMAGE: vcr.vercel.com/vercel/eve/base
+
jobs:
release:
runs-on: ubuntu-latest
@@ -42,6 +45,47 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
+ - name: Prepare VCR tag
+ if: github.ref == 'refs/heads/main'
+ id: vcr-tag
+ run: |
+ set -euo pipefail
+
+ version="$(jq -er '.version | select(type == "string" and length > 0)' packages/eve/package.json)"
+ echo "version=${version}" >>"$GITHUB_OUTPUT"
+ echo "tag=${VCR_IMAGE}:${version}" >>"$GITHUB_OUTPUT"
+
+ - name: Set up Docker Buildx
+ if: github.ref == 'refs/heads/main'
+ uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
+
+ - name: Log in to Vercel Container Registry
+ if: github.ref == 'refs/heads/main'
+ uses: vercel/vcr-login-action@9340c52f6b68b4758d9d2eebbd4c52b36e66f7f3 # main
+ with:
+ team: ${{ secrets.VCR_TEAM_ID }}
+
+ - name: Publish eve image to Vercel Container Registry
+ if: github.ref == 'refs/heads/main'
+ uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
+ with:
+ context: ./packages/eve
+ file: ./packages/eve/Dockerfile
+ platforms: linux/amd64
+ provenance: false
+ tags: |
+ ${{ steps.vcr-tag.outputs.tag }}
+ ${{ env.VCR_IMAGE }}:latest
+ labels: |
+ org.opencontainers.image.title=eve Sandbox
+ org.opencontainers.image.description=Sandbox base image for eve agents.
+ org.opencontainers.image.source=https://github.com/vercel/eve
+ org.opencontainers.image.revision=${{ github.sha }}
+ org.opencontainers.image.version=${{ steps.vcr-tag.outputs.version }}
+ outputs: type=image,push=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
# `commitMode: github-api` commits through @changesets/ghcommit, which
# reads the repo with isomorphic-git. Unlike git itself, isomorphic-git
# tries to parse every *.pack file in .git/objects/pack — including
diff --git a/.dockerignore b/packages/eve/.dockerignore
similarity index 100%
rename from .dockerignore
rename to packages/eve/.dockerignore
diff --git a/Dockerfile b/packages/eve/Dockerfile
similarity index 100%
rename from Dockerfile
rename to packages/eve/Dockerfile
diff --git a/packages/eve/src/execution/sandbox/bindings/docker-options.test.ts b/packages/eve/src/execution/sandbox/bindings/docker-options.test.ts
index b9dd979ac..0dce9d54d 100644
--- a/packages/eve/src/execution/sandbox/bindings/docker-options.test.ts
+++ b/packages/eve/src/execution/sandbox/bindings/docker-options.test.ts
@@ -5,9 +5,11 @@ import {
DEFAULT_DOCKER_SANDBOX_IMAGE,
resolveDockerSandboxOptions,
} from "#execution/sandbox/bindings/docker-options.js";
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
describe("resolveDockerSandboxOptions", () => {
it("defaults to eve's published sandbox runtime image with permissive networking", () => {
+ expect(DEFAULT_DOCKER_SANDBOX_IMAGE).toBe(DEFAULT_EVE_SANDBOX_IMAGE);
expect(resolveDockerSandboxOptions()).toEqual({
env: {},
image: DEFAULT_DOCKER_SANDBOX_IMAGE,
diff --git a/packages/eve/src/execution/sandbox/bindings/docker-options.ts b/packages/eve/src/execution/sandbox/bindings/docker-options.ts
index 59f617381..52db13cd8 100644
--- a/packages/eve/src/execution/sandbox/bindings/docker-options.ts
+++ b/packages/eve/src/execution/sandbox/bindings/docker-options.ts
@@ -1,5 +1,6 @@
import { createHash } from "node:crypto";
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
import type {
DockerSandboxCreateOptions,
DockerSandboxNetworkPolicy,
@@ -10,7 +11,7 @@ import type {
* Default base image for the Docker backend: eve's published sandbox
* runtime image.
*/
-export const DEFAULT_DOCKER_SANDBOX_IMAGE = "ghcr.io/vercel/eve:latest";
+export const DEFAULT_DOCKER_SANDBOX_IMAGE = DEFAULT_EVE_SANDBOX_IMAGE;
/**
* Fully-defaulted Docker backend options consumed by the backend
diff --git a/packages/eve/src/execution/sandbox/bindings/eve-image.ts b/packages/eve/src/execution/sandbox/bindings/eve-image.ts
new file mode 100644
index 000000000..2117114cf
--- /dev/null
+++ b/packages/eve/src/execution/sandbox/bindings/eve-image.ts
@@ -0,0 +1,10 @@
+import { resolveInstalledPackageInfo } from "#internal/application/package.js";
+
+const EVE_SANDBOX_IMAGE_REPOSITORY = "vcr.vercel.com/vercel/eve/base";
+
+// TODO: Replace with resolveEveSandboxImage() after the release workflow publishes its first VCR image.
+export const DEFAULT_EVE_SANDBOX_IMAGE = "ghcr.io/vercel/eve:latest";
+
+export function resolveEveSandboxImage(): string {
+ return `${EVE_SANDBOX_IMAGE_REPOSITORY}:${resolveInstalledPackageInfo().version}`;
+}
diff --git a/packages/eve/src/execution/sandbox/bindings/microsandbox-options.ts b/packages/eve/src/execution/sandbox/bindings/microsandbox-options.ts
index dc11046a2..1be9aed44 100644
--- a/packages/eve/src/execution/sandbox/bindings/microsandbox-options.ts
+++ b/packages/eve/src/execution/sandbox/bindings/microsandbox-options.ts
@@ -1,7 +1,8 @@
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
import type { MicrosandboxSandboxCreateOptions } from "#public/sandbox/microsandbox-sandbox.js";
import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
-export const MICROSANDBOX_DEFAULT_IMAGE = "ghcr.io/vercel/eve:latest";
+export const MICROSANDBOX_DEFAULT_IMAGE = DEFAULT_EVE_SANDBOX_IMAGE;
export const MICROSANDBOX_DEFAULT_CPUS = 1;
export const MICROSANDBOX_DEFAULT_MEMORY_MIB = 1024;
export const MICROSANDBOX_DEFAULT_PULL_POLICY = "if-missing";
diff --git a/packages/eve/src/execution/sandbox/bindings/microsandbox.test.ts b/packages/eve/src/execution/sandbox/bindings/microsandbox.test.ts
index 4f8aae65f..211a9c2e7 100644
--- a/packages/eve/src/execution/sandbox/bindings/microsandbox.test.ts
+++ b/packages/eve/src/execution/sandbox/bindings/microsandbox.test.ts
@@ -10,6 +10,7 @@ import {
MICROSANDBOX_DEFAULT_IMAGE,
resolveMicrosandboxOptions,
} from "#execution/sandbox/bindings/microsandbox-options.js";
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
const lifecycleMocks = vi.hoisted(() => ({
createMicrosandboxHandle: vi.fn(),
@@ -32,7 +33,7 @@ describe.skipIf(onWindows)("createMicrosandboxSandboxBackend", () => {
});
it("defaults to eve's published sandbox runtime image", () => {
- expect(MICROSANDBOX_DEFAULT_IMAGE).toBe("ghcr.io/vercel/eve:latest");
+ expect(MICROSANDBOX_DEFAULT_IMAGE).toBe(DEFAULT_EVE_SANDBOX_IMAGE);
expect(resolveMicrosandboxOptions(undefined).image).toBe(MICROSANDBOX_DEFAULT_IMAGE);
});
diff --git a/packages/eve/src/execution/sandbox/bindings/vercel-create-sdk.ts b/packages/eve/src/execution/sandbox/bindings/vercel-create-sdk.ts
index 43f3deb15..da99e91da 100644
--- a/packages/eve/src/execution/sandbox/bindings/vercel-create-sdk.ts
+++ b/packages/eve/src/execution/sandbox/bindings/vercel-create-sdk.ts
@@ -1,4 +1,5 @@
import { getVercelSandboxFetch } from "#execution/sandbox/bindings/vercel-credentials.js";
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
import type {
VercelCreateOptions,
VercelModule,
@@ -42,9 +43,7 @@ export async function createVercelEveImageSandbox(input: {
return await input.sandboxModule.Sandbox.create({
...createOptions,
source,
- image: VERCEL_EVE_SANDBOX_IMAGE,
+ image: DEFAULT_EVE_SANDBOX_IMAGE,
fetch,
});
}
-
-const VERCEL_EVE_SANDBOX_IMAGE = "vercel/eve:latest";
diff --git a/packages/eve/src/execution/sandbox/bindings/vercel.test.ts b/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
index 84a4cdb29..febd3cf62 100644
--- a/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
+++ b/packages/eve/src/execution/sandbox/bindings/vercel.test.ts
@@ -4,6 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { SandboxTemplateNotProvisionedError } from "#public/definitions/sandbox-backend.js";
import { vercel } from "#public/sandbox/backends/vercel.js";
+import { DEFAULT_EVE_SANDBOX_IMAGE } from "#execution/sandbox/bindings/eve-image.js";
import { createVercelSandbox } from "#execution/sandbox/bindings/vercel.js";
// The credential fallback consults the developer's Vercel CLI auth and the
@@ -145,7 +146,7 @@ afterEach(() => {
});
describe("createVercelSandbox", () => {
- it("creates fresh Vercel sandboxes through the SDK with the eve image", async () => {
+ it("creates fresh Vercel sandboxes with eve's shared base image", async () => {
const templateSandbox = createMockSandbox({ name: "template-key" });
const fetch = vi.fn();
const sandboxModule = {
@@ -178,7 +179,7 @@ describe("createVercelSandbox", () => {
expect(sandboxModule.Sandbox.create).toHaveBeenCalledTimes(1);
expect(sandboxModule.Sandbox.create).toHaveBeenCalledWith(
expect.objectContaining({
- image: "vercel/eve:latest",
+ image: DEFAULT_EVE_SANDBOX_IMAGE,
name: "template-key",
networkPolicy: "allow-all",
persistent: false,
@@ -215,7 +216,7 @@ describe("createVercelSandbox", () => {
expect(sandboxModule.Sandbox.create).toHaveBeenCalledWith(
expect.objectContaining({
__experimentalFlag: "enabled",
- image: "vercel/eve:latest",
+ image: DEFAULT_EVE_SANDBOX_IMAGE,
}),
);
});
diff --git a/scripts/docker-image-size-report.mjs b/scripts/docker-image-size-report.mjs
index 410899276..90f2aef3f 100644
--- a/scripts/docker-image-size-report.mjs
+++ b/scripts/docker-image-size-report.mjs
@@ -163,7 +163,7 @@ function parseArguments(argv) {
baselineSizeBytes: null,
currentLabel: "current",
currentSizeBytes: null,
- imageLabel: "Dockerfile",
+ imageLabel: "packages/eve/Dockerfile",
outputJsonPath: null,
outputMarkdownPath: null,
};