|
1 | 1 | --- |
2 | 2 | title: "Self-Hosting" |
3 | | -description: "Configure Cursor for your documentation workflow" |
| 3 | +description: "Deploy E2B to your own cloud infrastructure" |
4 | 4 | icon: "server" |
5 | 5 | --- |
| 6 | + |
| 7 | +Self-hosting E2B allows you to deploy and manage whole E2B open-source stack on your own Google Cloud Platform (GCP) 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 with Amazon Web Services (AWS) support coming soon. |
| 11 | + |
| 12 | +<Note> |
| 13 | + If you are looking for managed solution, consider our [Bring Your Own Cloud](/deployment/byoc) offering that will |
| 14 | + bring you same security and control over your data without need to of managing own infrastructure. |
| 15 | +</Note> |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | + |
| 20 | +### Required Accounts |
| 21 | +- **Cloudflare account** - DNS management |
| 22 | +- **Domain on Cloudflare** - Your custom domain used for DNS |
| 23 | +- **Google Cloud Platform project** - Google Cloud infrastructure |
| 24 | +- **PostgreSQL database** - Supabase is supported |
| 25 | + |
| 26 | +### Required Tools |
| 27 | +- **Packer** - For building disk images |
| 28 | +- **Terraform** (v1.5.x) - Infrastructure as Code |
| 29 | +- **Google Cloud CLI** - GCP authentication and management |
| 30 | +- **Golang** - Required for building components |
| 31 | +- **Docker** - Container management |
| 32 | + |
| 33 | +### Optional Accounts |
| 34 | +- **Grafana Account** - For advanced monitoring dashboards |
| 35 | + |
| 36 | +## Architecture Overview |
| 37 | + |
| 38 | +Similar to our BYOC offering, self-hosting allows you to maintain complete control over your infrastructure: |
| 39 | + |
| 40 | +- **Sandbox templates, snapshots, and runtime logs** are stored within your GCP project |
| 41 | +- **System metrics** (anonymized cluster memory/CPU) can optionally be sent to E2B Cloud for observability |
| 42 | +- **All sensitive traffic** (build files, sandbox traffic, logs) stays within your infrastructure |
| 43 | + |
| 44 | +### Core Components |
| 45 | +- **Orchestrator**: Manages sandbox lifecycle and template building |
| 46 | +- **Edge Controller**: Routes traffic and provides cluster management API |
| 47 | +- **Monitoring**: Collects logs and metrics from orchestrators |
| 48 | +- **Storage**: Persistent storage for templates, snapshots, and logs |
| 49 | + |
| 50 | +## Deployment Steps |
| 51 | + |
| 52 | +### 1. Setup GCP Project |
| 53 | +Create a new GCP project dedicated to your E2B deployment. |
| 54 | + |
| 55 | +### 2. Configure Environment |
| 56 | +Create your environment configuration file (`.env.prod`, `.env.staging`, or `.env.dev`) from the provided template: |
| 57 | + |
| 58 | +```bash |
| 59 | +# Configure your PostgreSQL connection string |
| 60 | +DATABASE_URL=postgresql://username:password@host:port/database |
| 61 | + |
| 62 | +# Set your domain |
| 63 | +DOMAIN=your-domain.com |
| 64 | + |
| 65 | +# Configure Cloudflare credentials |
| 66 | +CLOUDFLARE_API_TOKEN=your-cloudflare-token |
| 67 | +``` |
| 68 | + |
| 69 | +### 3. Initialize Deployment |
| 70 | +```bash |
| 71 | +# Switch to your target environment |
| 72 | +make switch-env ENV=prod # or staging/dev |
| 73 | + |
| 74 | +# Login to Google Cloud |
| 75 | +make login-gcloud |
| 76 | + |
| 77 | +# Initialize Terraform |
| 78 | +make init |
| 79 | +``` |
| 80 | + |
| 81 | +### 4. Build and Deploy |
| 82 | +```bash |
| 83 | +# Build images and upload to GCP |
| 84 | +make build-and-upload |
| 85 | + |
| 86 | +# Copy public builds |
| 87 | +make copy-public-builds |
| 88 | + |
| 89 | +# Run database migrations |
| 90 | +make migrate |
| 91 | +``` |
| 92 | + |
| 93 | +### 5. Configure Secrets |
| 94 | +Create necessary secrets in GCP Secrets Manager for your deployment. |
| 95 | + |
| 96 | +### 6. Apply Infrastructure |
| 97 | +Use Terraform to apply your infrastructure configurations. |
| 98 | + |
| 99 | +## Usage |
| 100 | + |
| 101 | +Once deployed, you can interact with your self-hosted E2B instance: |
| 102 | + |
| 103 | +### SDK Usage |
| 104 | +```python |
| 105 | +from e2b import Sandbox |
| 106 | + |
| 107 | +# Pass your domain when creating sandboxes |
| 108 | +sandbox = Sandbox("Python3", domain="your-domain.com") |
| 109 | +``` |
| 110 | + |
| 111 | +### CLI Usage |
| 112 | +```bash |
| 113 | +E2B_DOMAIN=your-domain.com e2b sandbox create Python3 |
| 114 | +``` |
| 115 | + |
| 116 | +### Monitoring |
| 117 | +Access the Nomad web UI at `https://nomad.your-domain.com` for cluster monitoring. |
| 118 | + |
| 119 | +## Security Considerations |
| 120 | + |
| 121 | +- **Data Isolation**: All sandbox data remains within your GCP project |
| 122 | +- **TLS Encryption**: All communications are encrypted in transit |
| 123 | +- **Private Networks**: Configure internal load balancers and VPC peering for additional security |
| 124 | +- **Access Control**: Leverage GCP IAM for fine-grained access control |
| 125 | + |
| 126 | +## Scaling |
| 127 | + |
| 128 | +- **Horizontal Scaling**: Add more orchestrator and edge controller nodes |
| 129 | +- **Vertical Scaling**: Increase resources for existing nodes |
| 130 | +- **Auto-scaling**: Currently in development for future releases |
| 131 | + |
| 132 | +## Troubleshooting |
| 133 | + |
| 134 | +### Common Issues |
| 135 | + |
| 136 | +**GCP Quotas**: If quotas aren't visible in your project, create and delete a dummy VM to trigger GCP policy generation. |
| 137 | + |
| 138 | +**Firecracker Components**: If needed, you can build Firecracker components from source. |
| 139 | + |
| 140 | +**Support**: For deployment issues, open a GitHub issue or contact our enterprise support team. |
| 141 | + |
| 142 | +## FAQ |
| 143 | + |
| 144 | +### How is the cluster monitored? |
| 145 | +The cluster forwards anonymized metrics (CPU/memory usage) to the E2B control plane for observability and alerting. No sensitive information is transmitted. |
| 146 | + |
| 147 | +### Can the cluster automatically scale? |
| 148 | +Horizontal scaling is supported by adding orchestrator and edge controller nodes. Automatic scaling of orchestrator nodes is planned for future releases. |
| 149 | + |
| 150 | +### Are sandboxes accessible only from my private network? |
| 151 | +Yes. You can configure the load balancer as internal-only and set up VPC peering to keep all traffic within your private network. |
| 152 | + |
| 153 | +### How is secure communication ensured? |
| 154 | +All data between components is encrypted using TLS. VPC peering can be established for additional security with private load balancers. |
0 commit comments