From a3e9ced6c6bdb02bb3e838f96daef3d37aa77c27 Mon Sep 17 00:00:00 2001 From: TheRealToxicDev Date: Mon, 11 Aug 2025 05:55:49 -0600 Subject: [PATCH 1/3] fix(github): workflows e2b stuff again --- .github/workflows/publish.yml | 16 +++++++--------- scripts/build-and-publish.mjs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 60ed629..86b0ec6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,15 +1,12 @@ name: Publish Templates on: - push: - branches: [master] - paths: - - '**/e2b.Dockerfile' - - '**/e2b.toml' - - '**/compile_page.sh' - - 'scripts/**' - - '.github/workflows/publish.yml' - - '.github/workflows/build.yml' + workflow_run: + workflows: ["Build Templates"] + types: + - completed + branches: + - master concurrency: group: publish-templates-${{ github.ref }} @@ -17,6 +14,7 @@ concurrency: jobs: publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest permissions: contents: read diff --git a/scripts/build-and-publish.mjs b/scripts/build-and-publish.mjs index c272c91..80bfd52 100644 --- a/scripts/build-and-publish.mjs +++ b/scripts/build-and-publish.mjs @@ -66,7 +66,7 @@ async function main() { } if (!mode || mode === 'publish' || mode === 'all' || mode === '') { console.log(`\n=== Publishing: ${t} ===`); - await run('e2b', ['template', 'publish'], t); + await run('e2b', ['template', 'publish', '--yes'], t); } } From 7e6dca5b57239cf9bbed34ff5e855e3916351f39 Mon Sep 17 00:00:00 2001 From: TheRealToxicDev Date: Mon, 11 Aug 2025 12:01:09 -0600 Subject: [PATCH 2/3] update(sandbox): bump nextjs version to latest --- nextjs-radixui/e2b.Dockerfile | 2 +- nextjs-shadcn/e2b.Dockerfile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nextjs-radixui/e2b.Dockerfile b/nextjs-radixui/e2b.Dockerfile index fd38239..f444630 100644 --- a/nextjs-radixui/e2b.Dockerfile +++ b/nextjs-radixui/e2b.Dockerfile @@ -11,7 +11,7 @@ RUN chmod +x /compile_page.sh WORKDIR /tmp/app # Create a fresh Next.js app (non-interactive) -RUN npx --yes create-next-app@15.3.3 . --yes +RUN npx --yes create-next-app@latest . --yes # Install Radix UI component packages RUN npm i --save \ diff --git a/nextjs-shadcn/e2b.Dockerfile b/nextjs-shadcn/e2b.Dockerfile index fd05025..5e867f7 100644 --- a/nextjs-shadcn/e2b.Dockerfile +++ b/nextjs-shadcn/e2b.Dockerfile @@ -10,10 +10,10 @@ RUN chmod +x /compile_page.sh # Install dependencies and customize sandbox in a temp directory WORKDIR /tmp/app -RUN npx --yes create-next-app@15.3.3 . --yes +RUN npx --yes create-next-app@latest . --yes -RUN npx --yes shadcn@2.6.3 init --yes -b neutral --force -RUN npx --yes shadcn@2.6.3 add --all --yes +RUN npx --yes shadcn@latest init --yes -b neutral --force +RUN npx --yes shadcn@latest add --all --yes # Copy everything (including dotfiles) to /home/user and remove temp dir to avoid nesting RUN mkdir -p /home/user \ From 7726b984ac738cc67a377d0f3256625a4c07e4bf Mon Sep 17 00:00:00 2001 From: TheRealToxicDev Date: Mon, 11 Aug 2025 13:58:09 -0600 Subject: [PATCH 3/3] fix(sandbox): downgrade resources and add nextjs with tailwind --- README.md | 3 +-- SECURITY.md | 4 ++-- nextjs-radixui/e2b.toml | 4 ++-- nextjs-shadcn/e2b.toml | 4 ++-- nextjs-tailwind/compile_page.sh | 20 ++++++++++++++++++++ nextjs-tailwind/e2b.Dockerfile | 19 +++++++++++++++++++ nextjs-tailwind/e2b.toml | 19 +++++++++++++++++++ 7 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 nextjs-tailwind/compile_page.sh create mode 100644 nextjs-tailwind/e2b.Dockerfile create mode 100644 nextjs-tailwind/e2b.toml diff --git a/README.md b/README.md index 19fe1c6..9fb672e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ ## Code0 Sandbox Templates -[![Publish Templates](https://github.com/Code0App/templates/actions/workflows/publish.yml/badge.svg)](https://github.com/Code0App/templates/actions/workflows/publish.yml) -[![Build Templates](https://github.com/Code0App/templates/actions/workflows/build.yml/badge.svg)](https://github.com/Code0App/templates/actions/workflows/build.yml) +[![Publish Templates](https://github.com/Code0App/templates/actions/workflows/publish.yml/badge.svg)](https://github.com/Code0App/templates/actions/workflows/publish.yml) [![Build Templates](https://github.com/Code0App/templates/actions/workflows/build.yml/badge.svg)](https://github.com/Code0App/templates/actions/workflows/build.yml) Sandbox images that power Code0 projects. These templates provide ready-to-run environments in E2B Cloud for building, previewing, and iterating on code generated by the app. diff --git a/SECURITY.md b/SECURITY.md index 04fb0d4..82a0fa6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -9,7 +9,7 @@ This folder contains E2B sandbox templates used to spin up ephemeral environment - If credentials were exposed (API keys, tokens), revoke/rotate them immediately and note this in your report. ## Scope -- Files under `sandbox/` (e.g., `nextjs/e2b.Dockerfile`, `e2b.toml`, shell scripts) and any artifacts they produce. +- Files under the root (e.g., `nextjs-shadcn/e2b.Dockerfile`, `e2b.toml`, shell scripts) and any artifacts they produce. - Runtime commands defined in `start_cmd` and installed packages in the image. ## Best Practices for Contributors @@ -20,7 +20,7 @@ This folder contains E2B sandbox templates used to spin up ephemeral environment - Use LF line endings for shell scripts and verify with `bash -n` locally when possible. ## Supported Templates -- Actively maintained templates live under `sandbox/`. Templates without recent updates may receive limited security backports. +- Actively maintained templates live inside this repo. Templates without recent updates may receive limited security backports. ## Disclosure Timeline - We aim to acknowledge within 3 business days and provide an initial assessment or mitigation plan within 10 business days. diff --git a/nextjs-radixui/e2b.toml b/nextjs-radixui/e2b.toml index 951ec2b..3193a6e 100644 --- a/nextjs-radixui/e2b.toml +++ b/nextjs-radixui/e2b.toml @@ -11,8 +11,8 @@ # const sandbox = await Sandbox.create('code0-nextjsradixui') team_id = "4465cfe3-5234-4e68-8099-a4df2df45079" -memory_mb = 8_192 -cpu_count = 8 +memory_mb = 4_192 +cpu_count = 4 start_cmd = "/compile_page.sh" dockerfile = "e2b.Dockerfile" template_name = "code0-nextjsradixui" diff --git a/nextjs-shadcn/e2b.toml b/nextjs-shadcn/e2b.toml index bd9e796..eaff6d3 100644 --- a/nextjs-shadcn/e2b.toml +++ b/nextjs-shadcn/e2b.toml @@ -11,8 +11,8 @@ # const sandbox = await Sandbox.create('code0-nextjsshadcn') team_id = "4465cfe3-5234-4e68-8099-a4df2df45079" -memory_mb = 8_192 -cpu_count = 8 +memory_mb = 4_192 +cpu_count = 4 start_cmd = "/compile_page.sh" dockerfile = "e2b.Dockerfile" template_name = "code0-nextjsshadcn" diff --git a/nextjs-tailwind/compile_page.sh b/nextjs-tailwind/compile_page.sh new file mode 100644 index 0000000..84b616e --- /dev/null +++ b/nextjs-tailwind/compile_page.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# This script runs during building the sandbox template +# and makes sure the Next.js app is (1) running and (2) the `/` page is compiled +function ping_server() { + counter=0 + response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000") + while [[ ${response} -ne 200 ]]; do + let counter++ + if (( counter % 20 == 0 )); then + echo "Waiting for server to start..." + sleep 0.1 + fi + + response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000") + done +} + +ping_server & +cd /home/user && npx next dev --turbopack diff --git a/nextjs-tailwind/e2b.Dockerfile b/nextjs-tailwind/e2b.Dockerfile new file mode 100644 index 0000000..99a1daa --- /dev/null +++ b/nextjs-tailwind/e2b.Dockerfile @@ -0,0 +1,19 @@ +# You can use most Debian-based base images +FROM node:21-slim + +# Install curl +RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY compile_page.sh /compile_page.sh +RUN chmod +x /compile_page.sh + +# Install dependencies and customize sandbox in a temp directory +WORKDIR /tmp/app + +# Create a fresh Next.js app with TailwindCSS (non-interactive) +RUN npx --yes create-next-app@latest . --yes + +# Copy everything (including dotfiles) to /home/user and remove temp dir to avoid nesting +RUN mkdir -p /home/user \ + && cp -a /tmp/app/. /home/user/ \ + && rm -rf /tmp/app \ No newline at end of file diff --git a/nextjs-tailwind/e2b.toml b/nextjs-tailwind/e2b.toml new file mode 100644 index 0000000..cbe3fe1 --- /dev/null +++ b/nextjs-tailwind/e2b.toml @@ -0,0 +1,19 @@ +# This is a config for E2B sandbox template. +# You can use template ID (zv80q8qolj5icz4kwejc) or template name (code0-nextjstailwind) to create a sandbox: + +# Python SDK +# from e2b import Sandbox, AsyncSandbox +# sandbox = Sandbox("code0-nextjstailwind") # Sync sandbox +# sandbox = await AsyncSandbox.create("code0-nextjstailwind") # Async sandbox + +# JS SDK +# import { Sandbox } from 'e2b' +# const sandbox = await Sandbox.create('code0-nextjstailwind') + +team_id = "4465cfe3-5234-4e68-8099-a4df2df45079" +memory_mb = 4_192 +cpu_count = 4 +start_cmd = "/compile_page.sh" +dockerfile = "e2b.Dockerfile" +template_name = "code0-nextjstailwind" +template_id = "zv80q8qolj5icz4kwejc"