Skip to content
中文

Custom templates

Official templates (base, browser, data, …) cover common work. When yours needs more, such as Docker, a CLI or pinned dependencies, make a custom template. Write a Dockerfile and the platform builds it in the cloud. Every sandbox started from the template then has all of it installed.

The API has the shape of E2B’s template builds: the official e2b SDK’s Template.build() works with apiUrl set to https://api.deepraxis.com/e2b. The examples below use the Praxis SDK.

Before you start

1. Build a template

import { Praxis } from "@deepraxis/sdk";
const praxis = new Praxis({ apiKey: process.env.PRAXIS_API_KEY! });
const build = await praxis.sandbox.templates.build({
name: "deploy-builder",
dockerfile: [
"FROM praxis/base",
"RUN curl -fsSL https://get.docker.com | sh",
"RUN npm install -g wrangler",
"WORKDIR /home/user",
].join("\n"),
cpuCount: 4,
memoryMB: 8192,
onLog: (entry) => console.log(entry.message),
});
console.log(build.status); // "ready"

build() reserves a build, submits the Dockerfile, and polls until the build finishes, passing each new log entry to onLog in order. A failed build throws an error carrying the reason and the last log lines. A template that installs a few packages is usually ready in about a minute.

Dockerfile rules:

  • The first FROM names an official template as praxis/<name>, or any public image such as FROM node:22.
  • RUN, ENV, WORKDIR and USER are supported.
  • COPY / ADD of local files is not supported yet; fetch files with RUN curl … or RUN git clone ….
  • Multi-stage builds (more than one FROM) are not supported.

2. Start a sandbox from it

终端窗口
curl https://api.deepraxis.com/sandbox/v1/sandboxes \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "content-type: application/json" \
-d '{"templateID": "deploy-builder", "timeout": 600, "autoPause": false}'

A bare template name uses the build that its default tag points to, which is the latest successful build.

3. Versions and rollback

Every build is an immutable version, numbered #1, #2, …

  • deploy-builder:b<n> pins build n, for example deploy-builder:b1.
  • deploy-builder:<tag> uses a tag you assigned, for example deploy-builder:stable.
  • Rolling back means moving default to an older build:
终端窗口
curl https://api.deepraxis.com/sandbox/v1/templates/tags \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "content-type: application/json" \
-d '{"target": "deploy-builder:b3", "tags": ["default"]}'

Building the same name again creates the next version under the same template ID. Tag names made of b and digits are reserved.

4. Private images

To build FROM a private registry, store its password or token in the vault. The build then references that secret instead of carrying the plaintext:

await praxis.sandbox.templates.build({
name: "pdf-ocr",
fromImage: "ghcr.io/acme/pdf-ocr:1.4",
fromImageRegistry: { type: "vault", vaultId: "vlt_…", secretName: "ghcr-token", username: "acme-bot" },
});

Without username, the build sends token, which works for GHCR and Alibaba ACR; Docker Hub needs the real user name. The password is used only during the build and never appears in build logs or storage.

In the Console

Console → Sandbox → Templates → New template offers three sources: Dockerfile, existing image or snapshot. A template’s page shows build progress and logs; its Versions tab sets the default and tags. The snapshot list’s row menu has Save as template.

Next