Skip to content

Commit 3b1f2e4

Browse files
committed
Add network isolation via ALLOWED_CIDRS and BLOCK_NETWORK
Configurable outbound CIDR allowlist and full network blocking for sandbox isolation. Update DEPLOY.md with GPU and network configuration docs.
1 parent 6d0f9cf commit 3b1f2e4

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

DEPLOY.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ This guide outlines the steps to deploy this project using Modal.
5555
WEBHOOK_SECRET=your_webhook_secret_here \
5656
ALLOWED_REPOS="owner/repo1,owner/repo2" \
5757
RUNNER_VERSION="2.311.0" \
58-
RUNNER_GROUP_ID="1" \
59-
RUNNER_LABELS='["self-hosted", "modal"]'
58+
RUNNER_GROUP_ID="1"
6059
```
6160

6261
5. **Deploy the app:**
@@ -78,6 +77,14 @@ This guide outlines the steps to deploy this project using Modal.
7877
runs-on: [self-hosted, modal]
7978
```
8079
80+
**GPU jobs:** Add a `gpu:` label to request GPU acceleration.
81+
82+
```yaml
83+
runs-on: [self-hosted, modal, gpu:t4]
84+
```
85+
86+
Supported GPU types: `gpu:t4`, `gpu:l4`, `gpu:a100`, `gpu:a100-80gb`, `gpu:h100`
87+
8188
### ⚠️ Security Considerations
8289
8390
* **Trust Model:** This runner executes with root privileges in isolated Modal sandboxes. Only allow trusted repositories via `ALLOWED_REPOS`.
@@ -101,7 +108,9 @@ Every time a job is queued, Modal will spawn an ephemeral sandbox that runs the
101108
| `GITHUB_TOKEN` | Yes | - | GitHub PAT for runner registration |
102109
| `WEBHOOK_SECRET` | Yes | - | Secret for webhook signature validation |
103110
| `ALLOWED_REPOS` | No | (all) | Comma-separated allowlist of `owner/repo` |
104-
| `RUNNER_VERSION` | No | `2.311.0` | GitHub Actions runner version |
111+
| `RUNNER_VERSION` | No | `2.333.1` | GitHub Actions runner version |
105112
| `RUNNER_GROUP_ID` | No | `1` | Runner group ID |
106-
| `RUNNER_LABELS` | No | `["self-hosted", "modal"]` | JSON array of runner labels |
113+
| `MAX_CONCURRENT_PER_REPO` | No | (unlimited) | Max concurrent sandboxes per repo |
114+
| `ALLOWED_CIDRS` | No | (allow all) | Comma-separated CIDR ranges for outbound |
115+
| `BLOCK_NETWORK` | No | `false` | Fully isolate sandbox network |
107116
| `GITHUB_ENTERPRISE_DOMAIN` | No | - | Custom domain for GitHub Enterprise |

app.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def format(self, record: logging.LogRecord) -> str:
101101
"h100": "H100",
102102
}
103103

104+
ALLOWED_CIDRS_STR = os.environ.get("ALLOWED_CIDRS", "")
105+
ALLOWED_CIDRS = [c.strip() for c in ALLOWED_CIDRS_STR.split(",") if c.strip()] if ALLOWED_CIDRS_STR else None
106+
BLOCK_NETWORK = os.environ.get("BLOCK_NETWORK", "").lower() in ("true", "1", "yes")
107+
104108

105109
def _get_gpu_config(gpu_key: str):
106110
attr_name = GPU_LABEL_TO_ATTR.get(gpu_key)
@@ -673,6 +677,8 @@ async def github_webhook(request: Request):
673677
timeout=TIMEOUT_SECONDS,
674678
env={"GHA_JIT_CONFIG": jit_config},
675679
gpu=gpu_config,
680+
cidr_allowlist=ALLOWED_CIDRS,
681+
block_network=BLOCK_NETWORK,
676682
experimental_options={"enable_docker": True},
677683
)
678684

0 commit comments

Comments
 (0)