Skip to content

Commit f027b26

Browse files
committed
improve the migration guide
1 parent cc257e7 commit f027b26

File tree

1 file changed

+83
-9
lines changed

1 file changed

+83
-9
lines changed

template/migration.mdx

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,36 @@ description: "How to migrate from the legacy template definition"
44
icon: "forward-fast"
55
---
66

7+
We've made ready for you three ways how to migrate existing template to the new definition format.
8+
9+
- Using the migration command (recommended)
10+
- Using the `fromDockerfile()` method to parse existing Dockerfile
11+
- Building the Docker image manually and using `fromImage()` method
12+
13+
## Migration Command (Recommended)
14+
715
To migrate the existing template definition to the new format, follow these steps:
8-
1) Install the latest version of the [E2B CLI](https://e2b.dev/docs/cli)
9-
2) Navigate to the folder of your existing template definition (where you have `e2b.toml` and `e2b.Dockerfile` files).
10-
3) Run the migration command:
11-
```bash
12-
e2b template migrate
13-
```
14-
4) Follow the prompts to complete the migration process.
15-
5) Done
1616

17-
## Generated Output
17+
<Steps>
18+
<Step title="Install E2B CLI">
19+
Install the latest version of the [E2B CLI](https://e2b.dev/docs/cli)
20+
</Step>
21+
<Step title="Navigate to your template folder">
22+
Navigate to the folder of your existing template definition (where you have `e2b.toml` and `e2b.Dockerfile` files).
23+
</Step>
24+
<Step title="Run migration command">
25+
```bash
26+
e2b template migrate
27+
```
28+
</Step>
29+
<Step title="Follow the prompts">
30+
Follow the prompts to complete the migration process.
31+
</Step>
32+
<Step title="Done">
33+
</Step>
34+
</Steps>
35+
36+
### Generated Output
1837
The migration command generates three files (based on the selected language).
1938

2039

@@ -33,3 +52,58 @@ build_prod.py - Production build script
3352
```
3453

3554
</CodeGroup>
55+
56+
57+
## Using `fromDockerfile()` Method
58+
59+
If you want to keep using Dockerfile for your template, you can use the `fromDockerfile()` method.
60+
We'll automatically parse the Dockerfile for you and build the template based on it.
61+
You can find more at [Base Image](/template/customization/base-image#parsing-existing-dockerfiles).
62+
63+
<CodeGroup dropdown>
64+
65+
```typescript template.ts
66+
import { Template } from "e2b";
67+
68+
const template = Template()
69+
.fromDockerfile(dockerfileContent);
70+
```
71+
```python template.py
72+
from e2b import Template
73+
74+
template = (
75+
Template()
76+
.from_dockerfile(dockerfile_content)
77+
)
78+
```
79+
80+
</CodeGroup>
81+
82+
After the template definition, you can create the build scripts as described in the [Quickstart](/template/quickstart#create-a-development-build-script) section.
83+
84+
85+
## Using `fromImage()` Method
86+
87+
If you already have a Docker image built, or you want to keep building the Docker image yourself you can use the `fromImage()` method.
88+
Simply build the Docker image for the `linux/amd64` platform, push it to a registry of your choice and reference the image tag in the `fromImage()` method.
89+
You can also specify credentials for private registries as described in the [Base Image](/template/customization/base-image#custom-base-image) section.
90+
91+
92+
<CodeGroup dropdown>
93+
94+
```typescript template.ts
95+
import { Template } from "e2b";
96+
97+
const template = Template()
98+
.fromImage("image-tag");
99+
```
100+
```python template.py
101+
from e2b import Template
102+
103+
template = (
104+
Template()
105+
.from_image("image-tag")
106+
)
107+
```
108+
109+
</CodeGroup>

0 commit comments

Comments
 (0)