diff --git a/README.md b/README.md index 66c5f11..87a2413 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mintlify Starter Kit +# Mintlify Starter Kit . Use the starter kit to get your docs deployed and ready to customize. diff --git a/docs.json b/docs.json index 732b55e..ec17af9 100644 --- a/docs.json +++ b/docs.json @@ -33,6 +33,7 @@ "template/customization/error-handling" ] }, + "template/local-development", "template/examples", "template/migration" ] diff --git a/template/local-development.mdx b/template/local-development.mdx new file mode 100644 index 0000000..35a48f9 --- /dev/null +++ b/template/local-development.mdx @@ -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. + + + 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. + + +## Example + +Create a template file: + + + +```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") +``` + + +Then, create a conversion script to convert the template to a Dockerfile definition: + + + +```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)) +``` + + + +Run the conversion script, forwarding the output to a new Dockerfile file: + + + +```typescript +npx tsx dev.ts +``` + +```python +python dev.py +``` + + +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 + + + +| Method | Supported | Docker Equivalent | +| :--- | :----: | :--- | +| `fromBaseImage()` | | `FROM e2bdev/base` | +| `fromUbuntuImage()` | | `FROM ubuntu:version` | +| `fromNodeImage()` | | `FROM node:version` | +| `fromPythonImage()` | | `FROM python:version` | +| `fromDebianImage()` | | `FROM debian:version` | +| `fromImage()` | | `FROM custom-image` | +| `setEnvs()` | | `ENV key=value` | +| `runCmd()` | | `RUN command` | +| `setStartCmd()` | | `ENTRYPOINT command` | +| `setWorkdir()` | | `WORKDIR path` | +| `setUser()` | | `USER user` | +| `copy()` | | `COPY src dest` | +| `aptInstall()` | | `RUN apt-get update && apt-get install -y package` | +| `pipInstall()` | | `RUN pip install package` | +| `npmInstall()` | | `RUN npm install package` | +| `gitClone()` | | `RUN git clone repository` | +| `makeSymlink()` | | `RUN ln -s src dest` | +| `fromTemplate()` | | Not supported - templates based on other templates cannot be converted to Dockerfile | +| `fromDockerfile()` | | Not supported - parsing Dockerfiles is not supported for local development | +| `fromRegistry()` | | Not supported - registry authentication not supported for local development | +| `fromAWSRegistry()` | | Not supported - AWS registry authentication not supported for local development | +| `fromGCPRegistry()` | | Not supported - GCP registry authentication not supported for local development | +| `skipCache()` | | Not supported - cache invalidation is not applicable for Dockerfile conversion | +| `setReadyCmd()` | | Not supported - ready commands are E2B-specific and not part of Docker | + + + +| Method | Supported | Docker Equivalent | +| :--- | :----: | :--- | +| `from_base_image()` | | `FROM e2bdev/base` | +| `from_ubuntu_image()`| | `FROM ubuntu:version` | +| `from_node_image()` | | `FROM node:version` | +| `from_python_image()`| | `FROM python:version` | +| `from_debian_image()`| | `FROM debian:version` | +| `from_image()` | | `FROM custom-image` | +| `set_envs()` | | `ENV key=value` | +| `run_cmd()` | | `RUN command` | +| `set_start_cmd()` | | `ENTRYPOINT command` | +| `set_workdir()` | | `WORKDIR path` | +| `set_user()` | | `USER user` | +| `copy()` | | `COPY src dest` | +| `apt_install()` | | `RUN apt-get update && apt-get install -y package` | +| `pip_install()` | | `RUN pip install package` | +| `npm_install()` | | `RUN npm install package` | +| `git_clone()` | | `RUN git clone repository` | +| `make_symlink()` | | `RUN ln -s src dest` | +| `from_template()` | | Not supported - templates based on other templates cannot be converted to Dockerfile | +| `from_dockerfile()` | | Not supported - parsing Dockerfiles is not supported for local development | +| `from_registry()` | | Not supported - registry authentication not supported for local development | +| `from_aws_registry()`| | Not supported - AWS registry authentication not supported for local development | +| `from_gcp_registry()`| | Not supported - GCP registry authentication not supported for local development | +| `skip_cache()` | | Not supported - cache invalidation is not applicable for Dockerfile conversion | +| `set_ready_cmd()` | | Not supported - ready commands are E2B-specific and not part of Docker | + + \ No newline at end of file