Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add quickstart page about installing custom packages
Vasek Mlejnsky7fc0a0f81b02
diff --git a/apps/web/src/app/(docs)/docs/quickstart/install-custom-packages/page.mdx b/apps/web/src/app/(docs)/docs/quickstart/install-custom-packages/page.mdxindex d1ed69e3e..d457c521a 100644--- a/apps/web/src/app/(docs)/docs/quickstart/install-custom-packages/page.mdx+++ b/apps/web/src/app/(docs)/docs/quickstart/install-custom-packages/page.mdx@@ -2,15 +2,155 @@There are two ways to install custom packages in the E2B Sandbox.-1. Create a custom sandbox with [(TODO: link)sandbox template](/todo).-2. Install a package inside the sandbox during the runtime with a package manager of your choice.+1. [Create custom sandbox with preinstalled packages](#create-a-custom-sandbox).+2. [Install packages during the sandbox runtime](#install-packages-during-the-sandbox-runtime).----## 1. Create custom sandbox+## Create a custom sandboxUse this option if you know beforehand what packages you need in the sandbox.+Prerequisites:+- E2B CLI+- Docker running+<Note>+Custom sandbox template is a Docker image that we automatically convert to a sandbox that you can then start with our SDK.+</Note>+++### 1. Install E2B CLI+Install the [E2B CLI](https://npmjs.com/package/@e2b/cli) globally on your machine with NPM.+<CodeGroup isTerminalCommand>+```bash+npm i -g @e2b/cli+```+</CodeGroup>++### 2. Login to E2B CLI+Before you can create a custom sandbox, you need to login to E2B CLI.+<CodeGroup isTerminalCommand>+```bash+e2b auth login+```+</CodeGroup>++### 2. Initialize a sandbox template+<CodeGroup isTerminalCommand>+```bash+e2b sandbox template init+```+</CodeGroup>++### 3. Specify the packages you need in `e2b.Dockerfile`+Edit the E2B Dockerfile to install the packages you need.++<Note>+You need to use the `e2bdev/code-interpreter:latest` base image.+</Note>++<CodeGroup title="e2b.Dockerfile">+```bash+FROM e2bdev/code-interpreter:latest++RUN pip install cowsay+RUN npm install cowsay+```+</CodeGroup>++### 4. Build the sandbox template+Run the following command to build the sandbox template.+<CodeGroup isTerminalCommand>+```bash+e2b sandbox template build -c "/root/.jupyter/start-up.sh"+```+</CodeGroup>++This will take a while, as it convert the Docker image to a sandbox which is a small VM.+At the end of the process you will see the sandbox ID like this:+```+Running postprocessing. It can take up to few minutes.++Postprocessing finished.++✅ Building sandbox template YOUR_TEMPLATE_ID finished.+```++### 5. Start your custom sandbox+Now you can pass the template ID to the SDK to start your custom sandbox.+<CodeGroup>+```js+import { Sandbox } from '@e2b/code-interpreter'++const sbx = Sandbox.create({+ template: 'YOUR_TEMPLATE_ID',+})+```+```python+from e2b_code_interpreter import Sandbox++sbx = Sandbox(template='YOUR_TEMPLATE_ID')+```+</CodeGroup>++---+++## Install packages during the sandbox runtime+Use this option if don't know beforehand what packages you need in the sandbox. You can install packages with the package manager of your choice.++<Note>+The packages installed during the runtime are available only in the running sandbox instance.+When you start a new sandbox instance, the packages are not be available.+</Note>++### 1. Install Python packages with PIP+<CodeGroup>+```js+import { Sandbox } from '@e2b/code-interpreter'++const sbx = Sandbox.create()+sbx.commands.run('pip install cowsay') // This will install the cowsay package+sbx.runCode(`+ import cowsay+ cowsay.cow("Hello, world!")+`)+```+```python+from e2b_code_interpreter import Sandbox++sbx = Sandbox()+sbx.commands.run("pip install cowsay") # This will install the cowsay package+sbx.run_code("""+ import cowsay+ cowsay.cow("Hello, world!")+""")+```+</CodeGroup>+++### 2. Install Node.js packages with NPM+<CodeGroup>+```js+import { Sandbox } from '@e2b/code-interpreter'++const sbx = Sandbox.create()+sbx.commands.run('npm install cowsay') // This will install the cowsay package+sbx.runCode(`+ const cowsay = require('cowsay')+ console.log(cowsay.say({ text: 'Hello, world!' }))+`, { language: 'javascript' })+```+```python+from e2b_code_interpreter import Sandbox++sbx = Sandbox()+sbx.commands.run("npm install cowsay") # This will install the cowsay package+sbx.run_code("""+ import { say } from 'cowsay'+ console.log(say('Hello, world!'))+""", language="javascript")+```+</CodeGroup>-## 2. Install packages during the runtime\ No newline at end of filediff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsxindex bd344b351..3845993d6 100644--- a/apps/web/src/components/Navigation/routes.tsx+++ b/apps/web/src/components/Navigation/routes.tsx@@ -80,7 +80,7 @@ export const routes: NavGroup[] = [href: '/docs/quickstart/upload-download-files',},{- title: '* Install custom packages',+ title: 'Install custom packages',href: '/docs/quickstart/install-custom-packages',},],