|
| 1 | +## Development |
| 2 | + |
| 3 | +#### Building from Source |
| 4 | + |
| 5 | +```bash |
| 6 | +# Standard build (executor image pulled at runtime) |
| 7 | +docker build -t code-interpreter -f code-interpreter/Dockerfile . |
| 8 | + |
| 9 | +# Build with pre-loaded executor image for instant DinD startup |
| 10 | +./build-preloaded.sh code-interpreter:preloaded |
| 11 | +``` |
| 12 | + |
| 13 | +**Build arguments:** |
| 14 | +- `SKIP_NESTED_DOCKER=1` - Skip installing Docker entirely (only for Docker-out-of-Docker mode) |
| 15 | +- `PYTHON_EXECUTOR_DOCKER_IMAGE=custom/image` - Use a custom executor image |
| 16 | + |
| 17 | +#### Pre-loaded Images for Faster Startup |
| 18 | + |
| 19 | +For production or offline environments, you can build an image with the executor pre-embedded: |
| 20 | + |
| 21 | +```bash |
| 22 | +# Build pre-loaded image (includes executor, ~1GB larger but instant DinD startup) |
| 23 | +./build-preloaded.sh code-interpreter:preloaded |
| 24 | + |
| 25 | +# Run with instant startup (no pulling needed) |
| 26 | +docker run --rm -it \ |
| 27 | + --privileged \ |
| 28 | + -p 8000:8000 \ |
| 29 | + code-interpreter:preloaded |
| 30 | +``` |
| 31 | + |
| 32 | +This is ideal for: |
| 33 | +- Production deployments (predictable startup times) |
| 34 | +- Air-gapped/offline environments |
| 35 | +- CI/CD pipelines |
| 36 | +- Any scenario where you want instant DinD readiness |
| 37 | + |
| 38 | +### Local Deployment |
| 39 | + |
| 40 | +#### Prerequisites |
| 41 | + |
| 42 | +- Python 3.11 |
| 43 | +- Docker (for execution isolation) |
| 44 | +- [uv](https://github.com/astral-sh/uv) package manager (recommended) |
| 45 | + |
| 46 | +#### Running the Service |
| 47 | + |
| 48 | +```bash |
| 49 | +# Clone the repository |
| 50 | +git clone https://github.com/onyx-dot-app/code-interpreter.git |
| 51 | +cd code-interpreter |
| 52 | + |
| 53 | +# Activate a virtual environment |
| 54 | +python -m venv .venv |
| 55 | +source .venv/bin/activate |
| 56 | + |
| 57 | +# Install dependencies |
| 58 | +uv sync --locked |
| 59 | +``` |
| 60 | + |
| 61 | +```bash |
| 62 | +# Start the API server (defaults to 0.0.0.0:8000) |
| 63 | +code-interpreter-api |
| 64 | + |
| 65 | +# Or specify host/port via environment variables |
| 66 | +HOST=127.0.0.1 PORT=8080 code-interpreter-api |
| 67 | +``` |
| 68 | + |
| 69 | +### Code Quality |
| 70 | + |
| 71 | +```bash |
| 72 | +# Type checking (must pass strict mypy) |
| 73 | +mypy . |
| 74 | + |
| 75 | +# Linting |
| 76 | +ruff check . |
| 77 | + |
| 78 | +# Formatting |
| 79 | +ruff format . |
| 80 | + |
| 81 | +# Run all pre-commit hooks |
| 82 | +pre-commit run --all-files |
| 83 | +``` |
| 84 | + |
| 85 | +### Testing |
| 86 | + |
| 87 | +```bash |
| 88 | +# Run integration tests |
| 89 | +pytest tests/integration_tests -q |
| 90 | + |
| 91 | +# Run a specific test |
| 92 | +pytest tests/integration_tests/test_file.py::test_function_name -v |
| 93 | +``` |
0 commit comments