Skip to content

Commit 507f2eb

Browse files
authored
Desktop Template E2B SDK (#128)
* desktop template using templates sdk * progress * cursor suggestions * update pyproject.toml * format * updated version * updated template * typo
1 parent eae3b30 commit 507f2eb

20 files changed

Lines changed: 579 additions & 133 deletions

.github/workflows/template.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Build and push Desktop template
33
on:
44
push:
55
paths:
6-
- "template/**"
7-
- ".github/workflows/template.yml"
6+
- 'template/**'
7+
- '.github/workflows/template.yml'
88
branches:
99
- main
1010

@@ -23,6 +23,22 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v3
2525

26+
- name: Set up Python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: '3.12'
30+
31+
- name: Install and configure Poetry
32+
uses: snok/install-poetry@v1
33+
with:
34+
version: 2.1.1
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
installer-parallel: true
38+
39+
- name: Install dependencies
40+
run: poetry install
41+
2642
- name: Set up Docker Buildx
2743
uses: docker/setup-buildx-action@v3
2844

@@ -35,16 +51,12 @@ jobs:
3551
- name: Build and push to DockerHub
3652
run: |
3753
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/desktop:latest || true
38-
docker buildx build \
39-
--file Dockerfile \
54+
poetry run python build_docker.py | docker buildx build \
4055
--platform linux/amd64 \
4156
--push \
42-
--tag ${{ secrets.DOCKERHUB_USERNAME }}/desktop:latest .
43-
44-
- name: Install E2B CLI
45-
run: npm install -g @e2b/cli
57+
--tag ${{ secrets.DOCKERHUB_USERNAME }}/desktop:latest -f - files
4658
47-
- name: Build e2b
48-
run: e2b template build
59+
- name: Build E2B template
60+
run: poetry run python build_prod.py
4961
env:
50-
E2B_ACCESS_TOKEN: ${{ secrets.E2B_ACCESS_TOKEN }}
62+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,5 @@ cython_debug/
295295

296296
# SDK reference artifacts
297297
sdk_ref/
298+
299+
.ruff_cache/

template/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

template/Dockerfile

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

template/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# E2B Desktop Template
2+
3+
This is the template for the E2B Desktop Sandbox.
4+
5+
## Building the template
6+
7+
```bash
8+
poetry run python build_dev.py
9+
```
10+
11+
## Building the production image
12+
13+
```bash
14+
poetry run python build_prod.py
15+
```

template/build_dev.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from dotenv import load_dotenv
2+
from e2b import Template, default_build_logger
3+
from template import template_with_user_workdir
4+
5+
load_dotenv()
6+
7+
Template.build(
8+
template=template_with_user_workdir,
9+
alias="desktop-dev",
10+
cpu_count=8,
11+
memory_mb=8192,
12+
on_build_logs=default_build_logger(),
13+
)

template/build_docker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from e2b import Template
2+
from template import template
3+
4+
# output the template to stdout to pipe into docker buildx
5+
print(Template.to_dockerfile(template))

template/build_prod.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from dotenv import load_dotenv
2+
from e2b import Template, default_build_logger
3+
from template import template_with_user_workdir
4+
5+
load_dotenv()
6+
7+
Template.build(
8+
template_with_user_workdir,
9+
alias="desktop",
10+
cpu_count=8,
11+
memory_mb=8192,
12+
on_build_logs=default_build_logger(),
13+
)

template/e2b.Dockerfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

template/e2b.toml

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

0 commit comments

Comments
 (0)