Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,5 @@ cython_debug/

# SDK reference artifacts
sdk_ref/

.ruff_cache/
1 change: 1 addition & 0 deletions template/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
103 changes: 0 additions & 103 deletions template/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions template/desktop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Desktop template package
13 changes: 13 additions & 0 deletions template/desktop/build_dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dotenv import load_dotenv
from e2b_template import Template
from .template import template

load_dotenv()

Template.build(
template,
alias="desktop-dev",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
13 changes: 13 additions & 0 deletions template/desktop/build_prod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dotenv import load_dotenv
from e2b_template import Template
from .template import template

load_dotenv()

Template.build(
template,
alias="desktop",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
File renamed without changes.
File renamed without changes.
129 changes: 129 additions & 0 deletions template/desktop/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
from e2b_template import Template, wait_for_process

template = (
Template()
.from_image("ubuntu:22.04")
.set_envs(
{
# Avoid system prompts
"DEBIAN_FRONTEND": "noninteractive",
"DEBIAN_PRIORITY": "high",
# Pip settings
"PIP_DEFAULT_TIMEOUT": "100",
"PIP_DISABLE_PIP_VERSION_CHECK": "1",
"PIP_NO_CACHE_DIR": "1",
}
)
# Initial system setup and packages
# We are not using .apt_install() here because some packages have interactive prompts (keyboard layout setup, etc.)
.run_cmd(
[
"yes | unminimize",
"apt-get update",
"apt-get install -y \
xserver-xorg \
x11-xserver-utils \
xvfb \
x11-utils \
xauth \
xfce4 \
xfce4-goodies \
util-linux \
sudo \
curl \
git \
wget \
python3-pip \
xdotool \
scrot \
ffmpeg \
x11vnc \
net-tools \
netcat \
x11-apps \
libreoffice \
xpdf \
gedit \
xpaint \
tint2 \
galculator \
pcmanfm \
software-properties-common \
apt-transport-https \
libgtk-3-bin",
]
)
# Setup NoVNC and websockify
.run_cmd(
[
"git clone --branch e2b-desktop https://github.com/e2b-dev/noVNC.git /opt/noVNC",
"ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html",
"git clone --branch v0.12.0 https://github.com/novnc/websockify /opt/noVNC/utils/websockify",
]
)
# Install browsers and set up repositories
.run_cmd(
[
"add-apt-repository ppa:mozillateam/ppa",
"wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -",
'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list',
"wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -",
'add-apt-repository -y "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"',
"apt-get update",
]
)
# Install browsers and VS Code
.apt_install(["firefox-esr", "google-chrome-stable", "code"])
# Configure system settings
.run_cmd(
[
"ln -sf /usr/bin/xfce4-terminal.wrapper /etc/alternatives/x-terminal-emulator",
"update-alternatives --set x-www-browser /usr/bin/firefox-esr",
"mkdir -p /home/user/.config/Code/User",
"mkdir -p /home/user/.config/xfce4/xfconf/xfce-perchannel-xml/",
"update-desktop-database /usr/share/applications/",
]
)
# Copy all configuration files
.copy(
[
{
"src": "google-chrome.desktop",
"dest": "/usr/share/applications/google-chrome.desktop",
"forceUpload": False,
},
{
"src": "settings.json",
"dest": "/home/user/.config/Code/User/settings.json",
"forceUpload": False,
},
{
"src": "wallpaper.png",
"dest": "/usr/share/backgrounds/xfce/wallpaper.png",
"forceUpload": False,
},
{
"src": "xfce4-desktop.xml",
"dest": "/home/user/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml",
"forceUpload": False,
},
{
"src": "firefox-policies.json",
"dest": "/usr/lib/firefox-esr/distribution/policies.json",
"forceUpload": False,
},
{
"src": "firefox-autoconfig.js",
"dest": "/usr/lib/firefox-esr/defaults/pref/autoconfig.js",
"forceUpload": False,
},
{
"src": "firefox.cfg",
"dest": "/usr/lib/firefox-esr/firefox.cfg",
"forceUpload": False,
},
]
)
# Set start command to launch the desktop environment
# .set_start_cmd("startxfce4", wait_for_process("xfce4-session"))
)
File renamed without changes
File renamed without changes.
1 change: 0 additions & 1 deletion template/e2b.Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions template/e2b.toml

This file was deleted.

20 changes: 20 additions & 0 deletions template/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[project]
name = "e2b_desktop"
version = "0.1.0"
description = "E2B Desktop Template"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"e2b-template>=0.2.4",
"httpx>=0.28.1",
]

[dependency-groups]
dev = [
"dotenv>=0.9.9",
"ruff>=0.12.5",
]

[project.scripts]
build-dev = "desktop.build_dev"
build-prod = "desktop.build_prod"
Loading