You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-8Lines changed: 66 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,20 +2,78 @@
2
2
## Introduction
3
3
Dify-Sandbox offers a simple way to run untrusted code in a secure environment. It is designed to be used in a multi-tenant environment, where multiple users can submit code to be executed. The code is executed in a sandboxed environment, which restricts the resources and system calls that the code can access.
4
4
5
+
## Features
6
+
-**Multi-backend Support**: Supports both native Linux sandbox (chroot + seccomp) and agent-infra/sandbox for cross-platform isolation
7
+
-**Cross-platform**: When using agent-infra/sandbox backend, works on macOS, Linux, and Windows
8
+
-**Multiple Languages**: Supports Python 3 and Node.js code execution
9
+
-**Secure Isolation**: Hardware or OS-level isolation for secure code execution
10
+
-**Flexible Configuration**: Easy configuration via YAML file
11
+
5
12
## Use
6
-
### Requirements
7
-
DifySandbox currently only supports Linux, as it's designed for docker containers. It requires the following dependencies:
13
+
14
+
### Native Backend (Linux Only)
15
+
The native backend uses Linux chroot and seccomp for isolation.
16
+
17
+
#### Requirements
18
+
- Linux operating system
8
19
- libseccomp
9
20
- pkg-config
10
21
- gcc
11
-
- golang 1.20.6
22
+
- golang 1.25.4 or higher
12
23
13
-
### Steps
24
+
####Steps
14
25
1. Clone the repository using `git clone https://github.com/langgenius/dify-sandbox` and navigate to the project directory.
15
-
2. Run ./install.sh to install the necessary dependencies.
16
-
3. Run ./build/build_[amd64|arm64].sh to build the sandbox binary.
17
-
4. Run ./main to start the server.
26
+
2. Run `./install.sh` to install the necessary dependencies.
27
+
3. Run `./build/build_[amd64|arm64].sh` to build the sandbox binary.
28
+
4. Edit `conf/config.yaml` and set `sandbox_backend: "native"` (default).
29
+
5. Run `./main` to start the server.
30
+
31
+
### agent-infra/sandbox Backend (Cross-platform)
32
+
The sandbox backend uses [agent-infra/sandbox](https://github.com/agent-infra/sandbox) for cross-platform isolation.
33
+
34
+
#### Requirements
35
+
- Docker
36
+
- golang 1.25.4 or higher
37
+
38
+
#### Installation
39
+
Run the sandbox server using Docker:
40
+
41
+
**Default (global):**
42
+
```bash
43
+
docker run --security-opt seccomp=unconfined --rm -it -p 10000:8080 ghcr.io/agent-infra/sandbox:latest
44
+
```
45
+
46
+
**For users in mainland China:**
47
+
```bash
48
+
docker run --security-opt seccomp=unconfined --rm -it -p 10000:8080 enterprise-public-cn-beijing.cr.volces.com/vefaas-public/all-in-one-sandbox:latest
49
+
```
50
+
51
+
**Use a specific version** (format: `1.0.0.${version}`):
52
+
```bash
53
+
docker run --security-opt seccomp=unconfined --rm -it -p 10000:8080 ghcr.io/agent-infra/sandbox:1.0.0.150
54
+
```
55
+
56
+
Note: The command maps port 8080 in the container to port 10000 on the host to match the default configuration.
57
+
58
+
#### Configuration
59
+
Edit `conf/config.yaml`:
60
+
```yaml
61
+
# Use sandbox backend
62
+
sandbox_backend: "microsandbox"
63
+
64
+
microsandbox:
65
+
enabled: true
66
+
server_address: "http://127.0.0.1:10000"# sandbox server address
67
+
```
68
+
69
+
#### Steps
70
+
1. Clone the repository: `git clone https://github.com/langgenius/dify-sandbox`
71
+
2. Navigate to the project directory
72
+
3. Build the Go binary: `go build -o main ./cmd/server`
73
+
4. Configure `conf/config.yaml` with sandbox settings
74
+
5. Run `./main` to start the server
18
75
76
+
### Debugging
19
77
If you want to debug the server, firstly use build script to build the sandbox library binaries, then debug as you want with your IDE.
20
78
21
79
@@ -25,4 +83,4 @@ Refer to the [FAQ document](FAQ.md)
0 commit comments