ishaan1013 / sandbox

A cloud-based code editing environment with an AI copilot and real-time collaboration
MIT License
1.25k stars 95 forks source link

Implement secure cloud sandboxes with E2B #35

Closed jamesmurdza closed 1 week ago

jamesmurdza commented 2 weeks ago

Description

This PR removes the built in node-pty terminal and adds integration with E2B's sandbox API. This fixes security issues with deployment and allows any number of sandboxes to run simultaneously.

It also fixes several bugs:

Implementation

Notes/limitations:

Terminology: Because of the word "sandbox" is already commonplace in the code, I decided to call E2B sandboxes containers in the source. However it would make a lot of sense to call those sandboxes and call sandbox projects projects.

Testing

To test this PR:

  1. Add E2B_API_KEY to /backend/server/.env (available for free at E2B).
  2. Run the frontend and backend, and open any sandbox.
  3. Commands run in the terminal will indicate a fresh Debian Linux system.
  4. Run npm install && npm run dev in the terminal and refresh the preview panel to see the live preview.
  5. Edit a source code file and save changes to test hot reloading.
ishaan1013 commented 1 week ago

@jamesmurdza lgtm, great work