You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sandbox_quickstart.md 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. sidebar_position: 20
  3. slug: /sandbox_quickstart
  4. ---
  5. # Sandbox quickstart
  6. A secure, pluggable code execution backend designed for RAGFlow and other applications requiring isolated code execution environments.
  7. ## Features:
  8. - Seamless RAGFlow Integration — Works out-of-the-box with the code component of RAGFlow.
  9. - High Security — Uses gVisor for syscall-level sandboxing to isolate execution.
  10. - Customisable Sandboxing — Modify seccomp profiles easily to tailor syscall restrictions.
  11. - Pluggable Runtime Support — Extendable to support any programming language runtime.
  12. - Developer Friendly — Quick setup with a convenient Makefile.
  13. ## Architecture
  14. The architecture consists of isolated Docker base images for each supported language runtime, managed by the executor manager service. The executor manager orchestrates sandboxed code execution using gVisor for syscall interception and optional seccomp profiles for enhanced syscall filtering.
  15. ## Prerequisites
  16. - Linux distribution compatible with gVisor.
  17. - gVisor installed and configured.
  18. - Docker version 24.0.0 or higher.
  19. - Docker Compose version 2.26.1 or higher (similar to RAGFlow requirements).
  20. - uv package and project manager installed.
  21. - (Optional) GNU Make for simplified command-line management.
  22. ## Build Docker base images
  23. The sandbox uses isolated base images for secure containerised execution environments.
  24. Build the base images manually:
  25. ```bash
  26. docker build -t sandbox-base-python:latest ./sandbox_base_image/python
  27. docker build -t sandbox-base-nodejs:latest ./sandbox_base_image/nodejs
  28. ```
  29. Alternatively, build all base images at once using the Makefile:
  30. ```bash
  31. make build
  32. ```
  33. Next, build the executor manager image:
  34. ```bash
  35. docker build -t sandbox-executor-manager:latest ./executor_manager
  36. ```
  37. ## Running with RAGFlow
  38. 1. Verify that gVisor is properly installed and operational.
  39. 2. Configure the .env file located at docker/.env:
  40. - Uncomment sandbox-related environment variables.
  41. - Enable the sandbox profile at the bottom of the file.
  42. 3. Add the following entry to your /etc/hosts file to resolve the executor manager service:
  43. ```bash
  44. 127.0.0.1 sandbox-executor-manager
  45. ```
  46. 4. Start the RAGFlow service as usual.
  47. ## Running standalone
  48. ### Manual setup
  49. 1. Initialize the environment variables:
  50. ```bash
  51. cp .env.example .env
  52. ```
  53. 2. Launch the sandbox services with Docker Compose:
  54. ```bash
  55. docker compose -f docker-compose.yml up
  56. ```
  57. 3. Test the sandbox setup:
  58. ```bash
  59. source .venv/bin/activate
  60. export PYTHONPATH=$(pwd)
  61. uv pip install -r executor_manager/requirements.txt
  62. uv run tests/sandbox_security_tests_full.py
  63. ```
  64. ### Using Makefile
  65. Run all setup, build, launch, and tests with a single command:
  66. ```bash
  67. make
  68. ```
  69. ### Monitoring
  70. To follow logs of the executor manager container:
  71. ```bash
  72. docker logs -f sandbox-executor-manager
  73. ```
  74. Or use the Makefile shortcut:
  75. ```bash
  76. make logs
  77. ```