Skip to content

Commit 3fe440f

Browse files
authored
feat: add documentation for template versioning with tags (#83)
1 parent ad5b944 commit 3fe440f

17 files changed

Lines changed: 461 additions & 243 deletions

docs.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
"docs/template/defining-template",
108108
"docs/template/start-ready-command",
109109
"docs/template/build",
110-
"docs/template/aliases",
110+
"docs/template/names",
111+
"docs/template/tags",
111112
"docs/template/logging",
112113
"docs/template/error-handling",
113114
{
@@ -282,6 +283,11 @@
282283
}
283284
},
284285
"redirects": [
286+
{
287+
"source": "/docs/template/aliases",
288+
"destination": "/docs/template/names",
289+
"permanent": true
290+
},
285291
{
286292
"source": "/docs/sandbox-templates/overview",
287293
"destination": "/docs/sandbox-template",

docs/mcp/custom-templates.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export const template = Template()
2828
.fromTemplate("mcp-gateway")
2929
.addMcpServer(["browserbase", "exa"]);
3030

31-
await Template.build(template, {
32-
alias: "my-mcp-gateway",
31+
await Template.build(template, 'my-mcp-gateway', {
3332
cpuCount: 8,
3433
memoryMB: 8192,
3534
onBuildLogs: defaultBuildLogger(),
@@ -50,7 +49,7 @@ template = (
5049

5150
Template.build(
5251
template,
53-
alias="my-mcp-gateway",
52+
'my-mcp-gateway',
5453
cpu_count=8,
5554
memory_mb=8192,
5655
on_build_logs=default_build_logger(),
@@ -61,7 +60,7 @@ Template.build(
6160

6261
## Using the template
6362

64-
Once built, create sandboxes from your template alias. You still need to provide the configuration for each MCP server.
63+
Once built, create sandboxes from your template. You still need to provide the configuration for each MCP server.
6564

6665
<CodeGroup>
6766

docs/quickstart/install-custom-packages.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ import { Template, defaultBuildLogger } from 'e2b';
7171
import { template } from './template';
7272

7373
async function main() {
74-
await Template.build(template, {
75-
alias: "custom-packages",
74+
await Template.build(template, 'custom-packages', {
7675
cpuCount: 2,
7776
memoryMB: 2048,
7877
onBuildLogs: defaultBuildLogger(),
@@ -93,7 +92,7 @@ load_dotenv()
9392
if __name__ == '__main__':
9493
Template.build(
9594
template,
96-
alias="custom-packages",
95+
'custom-packages',
9796
cpu_count=2,
9897
memory_mb=2048,
9998
on_build_logs=default_build_logger(),

docs/template/aliases.mdx

Lines changed: 0 additions & 177 deletions
This file was deleted.

docs/template/build.mdx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ The `build` method builds the template and waits for the build to complete. It r
1010
<CodeGroup>
1111

1212
```typescript JavaScript & TypeScript wrap
13-
const buildInfo = await Template.build(template, {
14-
alias: 'my-template', // Template alias (required)
13+
const buildInfo = await Template.build(template, 'my-template', {
1514
cpuCount: 2, // CPU cores
1615
memoryMB: 2048, // Memory in MB
1716
skipCache: false, // Configure cache skip (except for files)
@@ -20,13 +19,13 @@ const buildInfo = await Template.build(template, {
2019
domain: 'your-domain', // Override domain
2120
})
2221

23-
// buildInfo contains: { alias, templateId, buildId }
22+
// buildInfo contains: { name, templateId, buildId }
2423
```
2524

2625
```python Python wrap
2726
build_info = Template.build(
2827
template,
29-
alias="my-template", # Template alias (required)
28+
'my-template',
3029
cpu_count=2, # CPU cores
3130
memory_mb=2048, # Memory in MB
3231
skip_cache=False, # Configure cache skip (except for files)
@@ -35,7 +34,7 @@ build_info = Template.build(
3534
domain="your-domain", # Override domain
3635
)
3736

38-
# build_info contains: BuildInfo(alias, template_id, build_id)
37+
# build_info contains: BuildInfo(name, template_id, build_id)
3938
```
4039

4140
</CodeGroup>
@@ -47,24 +46,23 @@ The `buildInBackground` method starts the build process and returns immediately
4746
<CodeGroup>
4847

4948
```typescript JavaScript & TypeScript wrap
50-
const buildInfo = await Template.buildInBackground(template, {
51-
alias: 'my-template',
49+
const buildInfo = await Template.buildInBackground(template, 'my-template', {
5250
cpuCount: 2,
5351
memoryMB: 2048,
5452
})
5553

56-
// Returns immediately with: { alias, templateId, buildId }
54+
// Returns immediately with: { name, templateId, buildId }
5755
```
5856

5957
```python Python wrap
6058
build_info = Template.build_in_background(
6159
template,
62-
alias="my-template",
60+
'my-template',
6361
cpu_count=2,
6462
memory_mb=2048,
6563
)
6664

67-
# Returns immediately with: BuildInfo(alias, template_id, build_id)
65+
# Returns immediately with: BuildInfo(name, template_id, build_id)
6866
```
6967

7068
</CodeGroup>
@@ -100,8 +98,7 @@ status = Template.get_build_status(
10098

10199
```typescript JavaScript & TypeScript wrap
102100
// Start build in background
103-
const buildInfo = await Template.buildInBackground(template, {
104-
alias: 'my-template',
101+
const buildInfo = await Template.buildInBackground(template, 'my-template', {
105102
cpuCount: 2,
106103
memoryMB: 2048,
107104
})
@@ -137,7 +134,7 @@ if (status === 'ready') {
137134
# Start build in background
138135
build_info = Template.build_in_background(
139136
template,
140-
alias="my-template",
137+
'my-template',
141138
cpu_count=2,
142139
memory_mb=2048,
143140
)

docs/template/caching.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,16 @@ To force rebuild the whole template, you can use also `skipCache`/`skip_cache` p
4343

4444
<CodeGroup>
4545

46-
```typescript JavaScript & TypeScript wrap highlight={3}
47-
Template.build(template, {
48-
alias: 'my-template',
46+
```typescript JavaScript & TypeScript wrap highlight={2}
47+
Template.build(template, 'my-template', {
4948
skipCache: true, // Configure cache skip (except for files)
5049
})
5150
```
5251

5352
```python Python wrap highlight={4}
5453
Template.build(
5554
template,
56-
alias="my-template",
55+
'my-template',
5756
skip_cache=True, # Configure cache skip (except for files)
5857
)
5958
```
@@ -91,7 +90,7 @@ template = (
9190

9291
## Use Case for Caching
9392
You can leverage caching to create templates with multiple variants (e.g., different RAM or CPU) while reusing the common layers.
94-
When building the template, just change the template alias to a specific RAM/CPU configuration (e.g., `my-template-2cpu-2gb`, `my-template-1cpu-4gb`), keep the rest of the template definition the same, and the build process will reuse the cached layers.
93+
When building the template, just change the template name to a specific RAM/CPU configuration (e.g., `my-template-2cpu-2gb`, `my-template-1cpu-4gb`), keep the rest of the template definition the same, and the build process will reuse the cached layers.
9594

9695
## Optimize Build Times
9796
To optimize build times, place frequently changing commands (e.g., copying source code) towards the end of your template definition. This way, earlier layers can be cached and reused more often.

docs/template/error-handling.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ The SDK provides specific error types:
1111
import { AuthError, BuildError, FileUploadError } from 'e2b';
1212

1313
try {
14-
await Template.build(template, {
15-
alias: "my-template",
16-
});
14+
await Template.build(template, 'my-template');
1715
} catch (error) {
1816
if (error instanceof AuthError) {
1917
console.error("Authentication failed:", error.message);
@@ -29,7 +27,7 @@ try {
2927
from e2b import AuthError, BuildError, FileUploadError
3028

3129
try:
32-
Template.build(template, alias="my-template")
30+
Template.build(template, 'my-template')
3331
except AuthError as error:
3432
print(f"Authentication failed: {error}")
3533
except FileUploadError as error:

docs/template/examples/claude-code.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ template = (
4141
import { Template, defaultBuildLogger } from 'e2b'
4242
import { template as claudeCodeTemplate } from './template'
4343

44-
Template.build(claudeCodeTemplate, {
45-
alias: 'claude-code',
44+
Template.build(claudeCodeTemplate, 'claude-code', {
4645
cpuCount: 1,
4746
memoryMB: 1024,
4847
onBuildLogs: defaultBuildLogger(),
@@ -54,8 +53,7 @@ Template.build(claudeCodeTemplate, {
5453
from e2b import Template, default_build_logger
5554
from .template import template as claudeCodeTemplate
5655

57-
Template.build(claudeCodeTemplate,
58-
alias="claude-code",
56+
Template.build(claudeCodeTemplate, 'claude-code',
5957
cpu_count=1,
6058
memory_mb=1024,
6159
on_build_logs=default_build_logger(),

0 commit comments

Comments
 (0)