|
| 1 | +--- |
| 2 | +title: "Self-Hosting" |
| 3 | +description: "Deploy E2B to your own cloud infrastructure" |
| 4 | +icon: "server" |
| 5 | +--- |
| 6 | + |
| 7 | +Self-hosting E2B allows you to deploy and manage the whole E2B open-source stack on your own infrastructure. |
| 8 | +This gives you full control over your sandboxes, data, and security policies. |
| 9 | + |
| 10 | +We are currently officially supporting self-hosting on Google Cloud Platform (GCP) with Amazon Web Services (AWS), and on-premise support is coming soon. |
| 11 | + |
| 12 | +<Note> |
| 13 | + If you are looking for a managed solution, consider our [Bring Your Own Cloud](/infrastructure/byoc) offering that will |
| 14 | + bring you the same security and control with the E2B team managing infrastructure for you. |
| 15 | +</Note> |
| 16 | + |
| 17 | +## Google Cloud Platform |
| 18 | + |
| 19 | +## Linux Machine |
| 20 | +All E2B services are AMD64 compatible and ready to be deployed on Ubuntu 22.04 machines. |
| 21 | +Tooling for on-premise clustering and load-balancing is **not yet officially supported**. |
| 22 | + |
| 23 | +### Service images |
| 24 | + |
| 25 | +For running E2B core, you need to build and deploy **API**, **Edge (client-proxy)**, and **Orchestrator** services. |
| 26 | +This will work on any Linux machine with Docker installed. Orchestrator is built with Docker but deployed as a static binary, because it needs precise control over the Firecracker MicroVMs in the host system. |
| 27 | + |
| 28 | +Building and provisioning services can be similar to what we do with Google Cloud Platform builds and Nomad jobs setup. |
| 29 | +Details about architecture can be found in our [architecture](/infrastructure/architecture) sections. |
| 30 | + |
| 31 | +### Client machine setup |
| 32 | + |
| 33 | +#### Configuration |
| 34 | + |
| 35 | +The Orchestrator (client) machine requires a precise setup to spawn and control Firecracker-based sandboxes. |
| 36 | +This includes a correct OS version installed (Ubuntu 22.04) with KVM. It's possible to run KVM with nested virtualization, but there are some performance drawbacks. |
| 37 | + |
| 38 | +Most of the configuration can be taken from our client [machine setup script](https://github.com/e2b-dev/infra/blob/main/packages/cluster/scripts/start-client.sh). |
| 39 | +There are adjustments for the maximum number of inodes, socket connections, NBD, and huge pages allocations needed for the MicroVM process to work properly. |
| 40 | + |
| 41 | +#### Static binaries |
| 42 | + |
| 43 | +There is a need for a few files and folders to be present on the machine. |
| 44 | +For correctly working sandbox spawning, you need to have Firecracker, Linux kernel, and Envd binaries. |
| 45 | +We are distributing a pre-built one in the public Google Cloud bucket. |
| 46 | + |
| 47 | +```bash |
| 48 | +# Access publicly available pre-built binaries |
| 49 | +gsutil cp -r gs://e2b-prod-public-builds . |
| 50 | +``` |
| 51 | + |
| 52 | +Static files and folder setup example. Please replace Linux and Firecracker with the versions you want to use. |
| 53 | +Ensure you use the same Linux and Firecracker versions for both sandbox build and spawning. |
| 54 | + |
| 55 | +```bash |
| 56 | +sudo mkdir -p /orchestrator/sandbox |
| 57 | +sudo mkdir -p /orchestrator/template |
| 58 | +sudo mkdir -p /orchestrator/build |
| 59 | + |
| 60 | +sudo mkdir /fc-envd |
| 61 | +sudo mkdir /fc-envs |
| 62 | +sudo mkdir /fc-vm |
| 63 | + |
| 64 | +# Replace with the source where you envd binary is hosted |
| 65 | +# Currently, envd needs to be taken from your source as we are not providing it. |
| 66 | +sudo curl -fsSL -o /fc-envd/envd ${source_url} |
| 67 | +sudo chmod +x /fc-envd/envd |
| 68 | + |
| 69 | +SOURCE_URL="https://storage.googleapis.com/e2b-prod-public-builds" |
| 70 | +KERNEL_VERSION="vmlinux-6.1.102" |
| 71 | +FIRECRACKER_VERSION="v1.12.1_d990331" |
| 72 | + |
| 73 | +# Download Kernel |
| 74 | +sudo mkdir -p /fc-kernels/vmlinux-${KERNEL_VERSION} |
| 75 | +sudo curl -fsSL -o /fc-kernels/${KERNEL_VERSION}/vmlinux.bin ${SOURCE_URL}/kernels/${KERNEL_VERSION}/vmlinux.bin |
| 76 | + |
| 77 | +# Download Firecracker |
| 78 | +sudo mkdir -p /fc-versions/${FIRECRACKER_VERSION} |
| 79 | +sudo curl -fsSL -o /fc-versions/${FIRECRACKER_VERSION}/firecracker ${SOURCE_URL}/firecrackers/${FIRECRACKER_VERSION}/firecracker |
| 80 | +sudo chmod +x /fc-versions/${FIRECRACKER_VERSION}/firecracker |
| 81 | +``` |
0 commit comments