diff --git a/.github/actions/build-cli/action.yml b/.github/actions/build-cli/action.yml new file mode 100644 index 0000000000..1a5cc6f91b --- /dev/null +++ b/.github/actions/build-cli/action.yml @@ -0,0 +1,41 @@ +name: 'Build and install E2B CLI' +description: >- + Builds the e2b CLI from source in this repo and installs it globally so the + `e2b` command is available on PATH. Assumes the repository has already been + checked out. + +runs: + using: 'composite' + steps: + - name: Parse .tool-versions + uses: wistia/parse-tool-versions@v2.1.1 + with: + filename: '.tool-versions' + uppercase: 'true' + prefix: 'tool_version_' + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: '${{ env.TOOL_VERSION_PNPM }}' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '${{ env.TOOL_VERSION_NODEJS }}' + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + + - name: Install dependencies + shell: bash + run: pnpm install --frozen-lockfile + + - name: Build the CLI + shell: bash + run: pnpm build + working-directory: ./packages/cli + + - name: Install the CLI globally + shell: bash + run: npm install -g . + working-directory: ./packages/cli diff --git a/.github/workflows/templates.yml b/.github/workflows/templates.yml index f4981a4f41..b874682de3 100644 --- a/.github/workflows/templates.yml +++ b/.github/workflows/templates.yml @@ -12,12 +12,12 @@ permissions: contents: read jobs: - buildAndPublish: + buildAndPushImage: defaults: run: working-directory: ./templates/base - name: Build and Push Images + name: Build and Push Image to DockerHub runs-on: ubuntu-22.04 steps: - name: Checkout repository @@ -39,3 +39,19 @@ jobs: --platform linux/amd64,linux/arm64 \ --push \ --tag ${{ secrets.DOCKERHUB_USERNAME }}/base:latest . + + buildTemplate: + name: Build and Publish E2B Template + runs-on: ubuntu-22.04 + env: + E2B_API_KEY: ${{ secrets.E2B_API_KEY }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build and install E2B CLI + uses: ./.github/actions/build-cli + + - name: Build and publish base template + working-directory: ./templates/base + run: e2b template create base --memory-mb 512 diff --git a/templates/base/e2b.Dockerfile b/templates/base/e2b.Dockerfile index 367b156b33..befa44d4f4 100644 --- a/templates/base/e2b.Dockerfile +++ b/templates/base/e2b.Dockerfile @@ -7,8 +7,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ gh; \ rm -rf /var/lib/apt/lists/* -RUN groupadd --gid 1000 node \ - && useradd --uid 1000 --gid node --shell /bin/bash --create-home node +RUN groupadd -r node && useradd -r -g node -s /bin/bash -m node ENV NODE_VERSION=20.9.0 diff --git a/templates/base/e2b.toml b/templates/base/e2b.toml deleted file mode 100644 index 065b509fc6..0000000000 --- a/templates/base/e2b.toml +++ /dev/null @@ -1,17 +0,0 @@ -# This is a config for E2B sandbox template. -# You can use template ID (rki5dems9wqfm4r03t7g) or template name (base) to create a sandbox: - -# Python SDK -# from e2b import Sandbox, AsyncSandbox -# sandbox = Sandbox("base") # Sync sandbox -# sandbox = await AsyncSandbox.create("base") # Async sandbox - -# JS SDK -# import { Sandbox } from 'e2b' -# const sandbox = await Sandbox.create('base') - -team_id = "460355b3-4f64-48f9-9a16-4442817f79f5" -memory_mb = 512 -dockerfile = "e2b.Dockerfile" -template_name = "base" -template_id = "rki5dems9wqfm4r03t7g"