Skip to content

Run the template build on the infrastructure #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

dobrac
Copy link
Contributor

@dobrac dobrac commented Jun 16, 2025

Add basic ability to run template building on the infrastructure directly, instead of using local Docker.

This PR adds the following endpoints

  • POST /v2/templates
  • GET /templates/{templateID}/files/{hash}
  • POST /v2/templates/{templateID}/builds/{buildID}

The flow is described here: https://www.notion.so/e2bdev/API-Communication-Spec-20db8c29687380ab802be1a6f23eabdd?source=copy_link

Required changes
In order to use the new builder, you need to first run make build-engine-template in the packages/shared package. The build engine Docker image is available under e2bdev/build-engine.

If the engine is not built or no steps are provided, you can still use the previous way where the already built Docker image is supplied.

Copy link

linear bot commented Jun 16, 2025

@dobrac dobrac self-assigned this Jun 16, 2025
@dobrac dobrac added the feature New feature label Jun 16, 2025
@dobrac dobrac force-pushed the experiment-run-the-docker-build-inside-of-firecracker-e2b-2147 branch 2 times, most recently from d06fdc7 to 251dcc1 Compare June 17, 2025 18:00
@dobrac dobrac force-pushed the experiment-run-the-docker-build-inside-of-firecracker-e2b-2147 branch from f571c59 to ce82650 Compare June 18, 2025 04:28
@dobrac dobrac force-pushed the experiment-run-the-docker-build-inside-of-firecracker-e2b-2147 branch from 61b0a20 to a19207e Compare June 18, 2025 06:11
@dobrac dobrac changed the title WIP: Run the template build on E2B infra Run the template build on E2B infra Jun 20, 2025
@dobrac dobrac force-pushed the experiment-run-the-docker-build-inside-of-firecracker-e2b-2147 branch from a19207e to 2bdcbd2 Compare June 20, 2025 21:57
@dobrac dobrac force-pushed the experiment-run-the-docker-build-inside-of-firecracker-e2b-2147 branch 2 times, most recently from a84461d to 33031ce Compare June 25, 2025 19:14
@dobrac dobrac changed the title Run the template build on E2B infra Run the template build on the infrastructure Jun 25, 2025
@dobrac dobrac marked this pull request as ready for review June 25, 2025 21:25
"500":
$ref: "#/components/responses/500"

/templates/{templateID}/files/{hash}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to prefix this one also with V2, because it's part of the new feature that comes by V2?

Copy link
Contributor Author

@dobrac dobrac Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made v2 only the endpoints, that have version two (we have the same example with sandboxes list), this one is new, so no v2 required here. V2 has nothing to do with the Build System V2, but I understand the question

Copy link
Member

@sitole sitole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some quick look nits for now

@@ -36,6 +37,10 @@ func (fs *FileSystemStorageProvider) GetDetails() string {
return fmt.Sprintf("[Local file storage, base path set to %s]", fs.basePath)
}

func (fs *FileSystemStorageProvider) SignedURL(_ context.Context, _ string, _ time.Duration) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will the testing of the new build system work in integration tests/environments without object storage?

@@ -75,6 +78,20 @@ func (a *AWSBucketStorageProvider) GetDetails() string {
return fmt.Sprintf("[AWS Storage, bucket set to %s]", a.bucketName)
}

func (a *AWSBucketStorageProvider) SignedURL(ctx context.Context, path string, ttl time.Duration) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we maybe name it with something like UploadSignedURL?

@@ -75,4 +113,7 @@ service TemplateService {

// todo (2025-05): this is deprecated, please use InfoService that is used for both orchestrator and template manager
rpc HealthStatus (google.protobuf.Empty) returns (HealthStatusResponse);

// TemplateLayerFilesUpload requests an upload URL for a file to be cached for the template build.
rpc TemplateLayerFilesUpload (TemplateLayerFilesUploadRequest) returns (TemplateLayerFilesUploadResponse);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will basically run for every file? So if I have a folder with hundreds 10s or 100s of files, it will run this many times? Of course, it will be ideally just for the first build, but still.

Can we not dot it array at least? Maybe it will not be sent in batches now, but just make the interface prepared for that.

Copy link
Contributor Author

@dobrac dobrac Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs for every layer, every layer is one tar file

# import { Sandbox } from 'e2b'
# const sandbox = await Sandbox.create('e2b-build-engine')

template_id = "p9kw2u9cc1zj1cov2zru"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this work on different clusters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is that it's the same as the base image. Then it's references by the alias. Do you think there will be any issues with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants