Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mintlify Starter Kit
# Mintlify Starter Kit .

Use the starter kit to get your docs deployed and ready to customize.

Expand Down
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"template/customization/error-handling"
]
},
"template/local-development",
"template/examples",
"template/migration"
]
Expand Down
153 changes: 153 additions & 0 deletions template/local-development.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
title: "Local Development"
description: "How to test templates locally"
icon: "code"
---

You can test Templates locally by converting them to a Docker-compatible container images that you can build and run locally.

<Warning>
E2B Templates do not map 1:1 to Dockerfiles. Only a limited set of methods are supported and converted to equivalent Docker instructions.

See [Compatibility](/template/local-development#compatibility) for more details.
</Warning>

## Example

Create a template file:

<CodeGroup dropdown>

```typescript template.ts
import { Template } from "e2b";

export const template = Template()
.fromBaseImage()
.setEnvs({
HELLO: "Hello, World!",
})
.runCmd("echo $HELLO")
```

```python template.py
from e2b import Template

template = (
Template()
.from_base_image()
.set_envs({"HELLO": "Hello, World!"})
.run_cmd("echo $HELLO")
```
</CodeGroup>

Then, create a conversion script to convert the template to a Dockerfile definition:

<CodeGroup dropdown>

```typescript dev.ts
import fs from "fs";
import { Template } from "e2b";
import { template } from "./template";

fs.writeFileSync("Dockerfile", Template.toDockerfile(template));
```

```python dev.py
from os import write
from e2b import Template
from template import template

write("Dockerfile", Template.to_dockerfile(template))
```

</CodeGroup>

Run the conversion script, forwarding the output to a new Dockerfile file:

<CodeGroup dropdown>

```typescript
npx tsx dev.ts
```

```python
python dev.py
```
</CodeGroup>

Should produce a Dockerfile in the current directory with the following content:

```dockerfile
FROM e2bdev/base
ENV HELLO="Hello, World!"
RUN echo $HELLO
```

Build a container image from the Dockerfile and run it locally:

```bash
docker build -t template .
docker run template
```

## Compatibility

<Tabs>
<Tab title="TypeScript">
| Method | Supported | Docker Equivalent |
| :--- | :----: | :--- |
| `fromBaseImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM e2bdev/base` |
| `fromUbuntuImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM ubuntu:version` |
| `fromNodeImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM node:version` |
| `fromPythonImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM python:version` |
| `fromDebianImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM debian:version` |
| `fromImage()` | <Icon icon="square-check" iconType="solid" /> | `FROM custom-image` |
| `setEnvs()` | <Icon icon="square-check" iconType="solid" /> | `ENV key=value` |
| `runCmd()` | <Icon icon="square-check" iconType="solid" /> | `RUN command` |
| `setStartCmd()` | <Icon icon="square-check" iconType="solid" /> | `ENTRYPOINT command` |
| `setWorkdir()` | <Icon icon="square-check" iconType="solid" /> | `WORKDIR path` |
| `setUser()` | <Icon icon="square-check" iconType="solid" /> | `USER user` |
| `copy()` | <Icon icon="square-check" iconType="solid" /> | `COPY src dest` |
| `aptInstall()` | <Icon icon="square-check" iconType="solid" /> | `RUN apt-get update && apt-get install -y package` |
| `pipInstall()` | <Icon icon="square-check" iconType="solid" /> | `RUN pip install package` |
| `npmInstall()` | <Icon icon="square-check" iconType="solid" /> | `RUN npm install package` |
| `gitClone()` | <Icon icon="square-check" iconType="solid" /> | `RUN git clone repository` |
| `makeSymlink()` | <Icon icon="square-check" iconType="solid" /> | `RUN ln -s src dest` |
| `fromTemplate()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - templates based on other templates cannot be converted to Dockerfile |
| `fromDockerfile()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - parsing Dockerfiles is not supported for local development |
| `fromRegistry()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - registry authentication not supported for local development |
| `fromAWSRegistry()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - AWS registry authentication not supported for local development |
| `fromGCPRegistry()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - GCP registry authentication not supported for local development |
| `skipCache()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - cache invalidation is not applicable for Dockerfile conversion |
| `setReadyCmd()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - ready commands are E2B-specific and not part of Docker |

</Tab>
<Tab title="Python">
| Method | Supported | Docker Equivalent |
| :--- | :----: | :--- |
| `from_base_image()` | <Icon icon="square-check" iconType="solid" /> | `FROM e2bdev/base` |
| `from_ubuntu_image()`| <Icon icon="square-check" iconType="solid" /> | `FROM ubuntu:version` |
| `from_node_image()` | <Icon icon="square-check" iconType="solid" /> | `FROM node:version` |
| `from_python_image()`| <Icon icon="square-check" iconType="solid" /> | `FROM python:version` |
| `from_debian_image()`| <Icon icon="square-check" iconType="solid" /> | `FROM debian:version` |
| `from_image()` | <Icon icon="square-check" iconType="solid" /> | `FROM custom-image` |
| `set_envs()` | <Icon icon="square-check" iconType="solid" /> | `ENV key=value` |
| `run_cmd()` | <Icon icon="square-check" iconType="solid" /> | `RUN command` |
| `set_start_cmd()` | <Icon icon="square-check" iconType="solid" /> | `ENTRYPOINT command` |
| `set_workdir()` | <Icon icon="square-check" iconType="solid" /> | `WORKDIR path` |
| `set_user()` | <Icon icon="square-check" iconType="solid" /> | `USER user` |
| `copy()` | <Icon icon="square-check" iconType="solid" /> | `COPY src dest` |
| `apt_install()` | <Icon icon="square-check" iconType="solid" /> | `RUN apt-get update && apt-get install -y package` |
| `pip_install()` | <Icon icon="square-check" iconType="solid" /> | `RUN pip install package` |
| `npm_install()` | <Icon icon="square-check" iconType="solid" /> | `RUN npm install package` |
| `git_clone()` | <Icon icon="square-check" iconType="solid" /> | `RUN git clone repository` |
| `make_symlink()` | <Icon icon="square-check" iconType="solid" /> | `RUN ln -s src dest` |
| `from_template()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - templates based on other templates cannot be converted to Dockerfile |
| `from_dockerfile()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - parsing Dockerfiles is not supported for local development |
| `from_registry()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - registry authentication not supported for local development |
| `from_aws_registry()`| <Icon icon="square-xmark" iconType="solid" /> | Not supported - AWS registry authentication not supported for local development |
| `from_gcp_registry()`| <Icon icon="square-xmark" iconType="solid" /> | Not supported - GCP registry authentication not supported for local development |
| `skip_cache()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - cache invalidation is not applicable for Dockerfile conversion |
| `set_ready_cmd()` | <Icon icon="square-xmark" iconType="solid" /> | Not supported - ready commands are E2B-specific and not part of Docker |
</Tab>
</Tabs>