start.sh


Overview

start.sh is a Bash shell script designed to automate the setup, cleanup, build, and launch process of the InfiniFlow sandbox executor environment. The script orchestrates Docker container lifecycle management, image building for Python and Node.js sandboxes, service startup via Docker Compose, connectivity and health checks, and final security validation tests.

This script streamlines the deployment of sandbox executor services by:

It is intended to be run from the root directory of the InfiniFlow project and assumes the presence of Docker, Docker Compose, and some auxiliary scripts for health checks.


Detailed Explanation

Environment Configuration

Variable

Description

Default

SANDBOX_EXECUTOR_MANAGER_PORT

TCP port where executor manager listens

9385

SANDBOX_EXECUTOR_MANAGER_POOL_SIZE

Number of sandbox executor containers to maintain

5

SANDBOX_BASE_PYTHON_IMAGE

Docker image tag for the Python sandbox base image

sandbox-base-python:latest

SANDBOX_BASE_NODEJS_IMAGE

Docker image tag for the Node.js sandbox base image

sandbox-base-nodejs:latest

If the .env file is missing, the script prints a warning and falls back on these default values.


Step 1: Build sandbox-base images

Usage Example:

./start.sh
# Output will include docker build progress for sandbox-base-python and sandbox-base-nodejs images.

Step 2: Clean up old sandbox containers

This ensures a clean slate before starting new containers.


Step 3: Build executor services


Step 4: Start services


Step 5: Health checks

Divided into two substeps to ensure the services are ready:

These checks help catch startup failures early.


Step 6: Run security tests


Final Output

Service is ready: http://localhost:<port>/docs

Important Implementation Details


Interaction with Other Parts of the System


Usage Summary

Run this script from the root project directory to deploy the sandbox executor environment:

./start.sh

It will build images, clean up old containers, launch services, perform health checks, and run security validations automatically.


Mermaid Flowchart Diagram

The following flowchart illustrates the high-level workflow and relationships between key steps and components in start.sh:

flowchart TD
    A[Start: Run start.sh] --> B[Set BASE_DIR and cd]
    B --> C{.env file exists?}
    C -- Yes --> D[Source .env and set variables]
    C -- No --> E[Set default variables and warn]
    D --> F[Build sandbox-base images for Python & Node.js]
    E --> G[Skip build]
    F --> H[Cleanup old sandbox containers]
    G --> H
    H --> I[Build executor services (docker compose build)]
    I --> J[Start services (docker compose up -d)]
    J --> K[Wait for TCP port to open (wait-for-it.sh)]
    K --> L[Check HTTP health endpoint (/healthz)]
    L --> M[Run security tests (sandbox_security_tests_full.py)]
    M --> N[Print success message with service URL]
    N --> O[End]

    style C fill:#f9f,stroke:#333,stroke-width:1px
    style F fill:#bbf,stroke:#333,stroke-width:1px
    style H fill:#bbf,stroke:#333,stroke-width:1px
    style I fill:#bbf,stroke:#333,stroke-width:1px
    style J fill:#bbf,stroke:#333,stroke-width:1px
    style K fill:#bbf,stroke:#333,stroke-width:1px
    style L fill:#bbf,stroke:#333,stroke-width:1px
    style M fill:#bbf,stroke:#333,stroke-width:1px
    style N fill:#afa,stroke:#333,stroke-width:1px

Summary

start.sh is a comprehensive bootstrap script that prepares, cleans, builds, launches, verifies, and validates the InfiniFlow sandbox executor environment in a reliable and automated manner. It acts as the main entry point for developers or operators to deploy and test the sandbox executor manager and related services locally using Docker containers.