SDK: fromFedoraImage/fromAlpineImage/fromArchImage helpers (#1612)
## What Adds the missing non-Debian base-image convenience helpers to **both SDKs**, mirroring the existing `fromUbuntuImage`/`fromDebianImage`/`fromPythonImage`/`fromNodeImage`/`fromBunImage`: - **JS/TS** (`packages/js-sdk`): `fromFedoraImage(variant?)`, `fromAlpineImage(variant?)`, `fromArchImage(variant?)` + unit tests - **Python** (`packages/python-sdk`): `from_fedora_image(variant)`, `from_alpine_image(variant)`, `from_arch_image(variant)` + sync/async unit tests ## Why This is the **customer-facing half** of infra **#3381** (distro-aware template provisioning). The engine now builds + boots Ubuntu/Debian/Fedora/RHEL-family/Arch/Alpine on real KVM; before this PR the SDK exposed distro helpers for the Debian family only, so Fedora/Alpine/Arch were reachable only via the generic `fromImage()`. These give them first-class parity. ## Verification (honest) - **New helper unit tests pass locally** — JS `fromDistroImages.test.ts` → 6/6 green (`vitest`, no auth). Python `test_from_distro_images.py` (sync + async) committed. - **Full integration suite**: requires E2B API keys — fails locally with `AuthenticationError` **identically on `main`** (215/187/29), i.e. **zero regression** from this change; CI runs it with secrets. - Lint scoped to the touched files. ## Not in this PR The public **docs** still state *"only Debian-based images … Alpine/RedHat not supported"* — but that text lives in **`e2b-dev/docs`**, not this monorepo, so it's a **separate docs PR** (being opened against `e2b-dev/docs`). Flagging so this + that land together. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'e2b': minor
|
||||
'@e2b/python-sdk': minor
|
||||
---
|
||||
|
||||
Add `fromFedoraImage`, `fromAlpineImage`, and `fromArchImage` base-image helpers to the `Template` builder (`from_fedora_image`, `from_alpine_image`, `from_arch_image` in the Python SDK), alongside the existing `fromUbuntuImage`/`fromDebianImage`/etc. Templates can now start from Fedora, Alpine, and Arch base images (the orchestrator identifies the distro from `/etc/os-release`). Fedora and Alpine default to pinned tags (`fedora:44`, `alpine:3.24`) so builds stay reproducible; Arch defaults to `latest` because it is a rolling release and provisioning runs `pacman -Syu` regardless.
|
||||
@@ -426,6 +426,20 @@ export class TemplateBase
|
||||
return this.fromImage(`ubuntu:${variant}`)
|
||||
}
|
||||
|
||||
fromFedoraImage(variant: string = '44'): TemplateBuilder {
|
||||
return this.fromImage(`fedora:${variant}`)
|
||||
}
|
||||
|
||||
fromAlpineImage(variant: string = '3.24'): TemplateBuilder {
|
||||
return this.fromImage(`alpine:${variant}`)
|
||||
}
|
||||
|
||||
// Left on `latest`: Arch is a rolling release and template provisioning runs
|
||||
// `pacman -Syu`, so pinning a tag would not change the built result.
|
||||
fromArchImage(variant: string = 'latest'): TemplateBuilder {
|
||||
return this.fromImage(`archlinux:${variant}`)
|
||||
}
|
||||
|
||||
fromPythonImage(version: string = '3'): TemplateBuilder {
|
||||
return this.fromImage(`python:${version}`)
|
||||
}
|
||||
|
||||
@@ -245,6 +245,42 @@ export interface TemplateFromImage {
|
||||
*/
|
||||
fromUbuntuImage(variant?: string): TemplateBuilder
|
||||
|
||||
/**
|
||||
* Start from a Fedora-based Docker image.
|
||||
* @param variant Fedora variant (default: '42')
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* Template().fromFedoraImage('42')
|
||||
* ```
|
||||
*/
|
||||
fromFedoraImage(variant?: string): TemplateBuilder
|
||||
|
||||
/**
|
||||
* Start from an Alpine-based Docker image.
|
||||
* @param variant Alpine variant (default: '3.22')
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* Template().fromAlpineImage('3.22')
|
||||
* ```
|
||||
*/
|
||||
fromAlpineImage(variant?: string): TemplateBuilder
|
||||
|
||||
/**
|
||||
* Start from an Arch Linux-based Docker image.
|
||||
*
|
||||
* Defaults to `latest`: Arch is a rolling release and template provisioning
|
||||
* runs `pacman -Syu`, so pinning a tag would not change the built result.
|
||||
* @param variant Arch Linux variant (default: 'latest')
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* Template().fromArchImage('base-devel')
|
||||
* ```
|
||||
*/
|
||||
fromArchImage(variant?: string): TemplateBuilder
|
||||
|
||||
/**
|
||||
* Start from a Python-based Docker image.
|
||||
* @param version Python version (default: '3')
|
||||
|
||||
@@ -846,6 +846,55 @@ class TemplateBase:
|
||||
"""
|
||||
return self.from_image(f"ubuntu:{variant}")
|
||||
|
||||
def from_fedora_image(self, variant: str = "42") -> TemplateBuilder:
|
||||
"""
|
||||
Start template from a Fedora base image.
|
||||
|
||||
:param variant: Fedora image variant (default: '42')
|
||||
|
||||
:return: `TemplateBuilder` class
|
||||
|
||||
Example
|
||||
```python
|
||||
Template().from_fedora_image('42')
|
||||
```
|
||||
"""
|
||||
return self.from_image(f"fedora:{variant}")
|
||||
|
||||
def from_alpine_image(self, variant: str = "3.22") -> TemplateBuilder:
|
||||
"""
|
||||
Start template from an Alpine base image.
|
||||
|
||||
:param variant: Alpine image variant (default: '3.22')
|
||||
|
||||
:return: `TemplateBuilder` class
|
||||
|
||||
Example
|
||||
```python
|
||||
Template().from_alpine_image('3.22')
|
||||
```
|
||||
"""
|
||||
return self.from_image(f"alpine:{variant}")
|
||||
|
||||
def from_arch_image(self, variant: str = "latest") -> TemplateBuilder:
|
||||
"""
|
||||
Start template from an Arch Linux base image.
|
||||
|
||||
Defaults to `latest`: Arch is a rolling release and template
|
||||
provisioning runs `pacman -Syu`, so pinning a tag would not change
|
||||
the built result.
|
||||
|
||||
:param variant: Arch Linux image variant (default: 'latest')
|
||||
|
||||
:return: `TemplateBuilder` class
|
||||
|
||||
Example
|
||||
```python
|
||||
Template().from_arch_image('base-devel')
|
||||
```
|
||||
"""
|
||||
return self.from_image(f"archlinux:{variant}")
|
||||
|
||||
def from_python_image(self, version: str = "3") -> TemplateBuilder:
|
||||
"""
|
||||
Start template from a Python base image.
|
||||
|
||||
Reference in New Issue
Block a user