sandboxbox 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Dockerfile CHANGED
@@ -1,39 +1,95 @@
1
- FROM ubuntu:24.04
1
+ FROM node:20
2
2
 
3
- # Set up code user
4
- RUN useradd code
3
+ ARG TZ
4
+ ENV TZ="$TZ"
5
5
 
6
- RUN chsh -s /bin/bash code
6
+ ARG CLAUDE_CODE_VERSION=latest
7
7
 
8
- RUN mkdir /home/code
9
- RUN chown code:code /home/code
8
+ # Install basic development tools and iptables/ipset
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ less \
11
+ git \
12
+ procps \
13
+ sudo \
14
+ fzf \
15
+ zsh \
16
+ man-db \
17
+ unzip \
18
+ gnupg2 \
19
+ gh \
20
+ iptables \
21
+ ipset \
22
+ iproute2 \
23
+ dnsutils \
24
+ aggregate \
25
+ jq \
26
+ nano \
27
+ vim \
28
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
10
29
 
11
- # Install deps
30
+ # Ensure default node user has access to /usr/local/share
31
+ RUN mkdir -p /usr/local/share/npm-global && \
32
+ chown -R node:node /usr/local/share
12
33
 
13
- ENV USE_BUILTIN_RIPGREP=0
14
- RUN apt-get update && apt-get install -y \
15
- postgresql-client nodejs npm curl sudo neovim direnv supervisor
34
+ ARG USERNAME=node
16
35
 
17
- # Install playwright deps
18
- RUN npx --yes playwright install-deps
36
+ # Persist bash history.
37
+ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
38
+ && mkdir -p /commandhistory \
39
+ && touch /commandhistory/.bash_history \
40
+ && chown -R $USERNAME /commandhistory
19
41
 
20
- RUN npm i -g @playwright/mcp
42
+ # Set `DEVCONTAINER` environment variable to help with orientation
43
+ ENV DEVCONTAINER=true
44
+
45
+ # Create workspace and config directories and set permissions
46
+ RUN mkdir -p /workspace /home/node/.claude && \
47
+ chown -R node:node /workspace /home/node/.claude
48
+
49
+ WORKDIR /workspace
21
50
 
22
- # Install pnpm and configure it to be global
51
+ ARG GIT_DELTA_VERSION=0.18.2
52
+ RUN ARCH=$(dpkg --print-architecture) && \
53
+ wget "https://github.com/dandavison/delta/releases/download/${GIT_DELTA_VERSION}/git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \
54
+ sudo dpkg -i "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \
55
+ rm "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb"
23
56
 
24
- RUN npm i -g pnpm
57
+ # Set up non-root user
58
+ USER node
25
59
 
26
- RUN mkdir -p /usr/local/share/pnpm/global/bin
60
+ # Install global packages
61
+ ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
62
+ ENV PATH=$PATH:/usr/local/share/npm-global/bin
27
63
 
28
- RUN pnpm config set global-bin-dir /usr/local/share/pnpm/global/bin
29
- RUN pnpm config set global-dir /usr/local/share/pnpm
30
- RUN echo 'export PATH="/usr/local/share/pnpm/global/bin:$PATH"' | tee -a /etc/bash.bashrc
64
+ # Set the default shell to zsh rather than sh
65
+ ENV SHELL=/bin/zsh
31
66
 
32
- RUN bash -c 'PATH="/usr/local/share/pnpm/global/bin:$PATH" && pnpm i -g @anthropic-ai/claude-code'
67
+ # Set the default editor and visual
68
+ ENV EDITOR=nano
69
+ ENV VISUAL=nano
33
70
 
34
- USER code
71
+ # Default powerline10k theme
72
+ ARG ZSH_IN_DOCKER_VERSION=1.2.0
73
+ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v${ZSH_IN_DOCKER_VERSION}/zsh-in-docker.sh)" -- \
74
+ -p git \
75
+ -p fzf \
76
+ -a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \
77
+ -a "source /usr/share/doc/fzf/examples/completion.zsh" \
78
+ -a "export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
79
+ -x
35
80
 
36
- # Install chromium. Has to be done using the playwright MCP version for proper pathing etc
37
- RUN node /usr/local/lib/node_modules/@playwright/mcp/node_modules/playwright/cli.js install chromium
81
+ # Install Claude
82
+ RUN npm install -g @anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}
83
+
84
+ # Install playwright deps
85
+ RUN npx --yes playwright install-deps
86
+
87
+ RUN npm i -g @playwright/mcp
38
88
 
39
- CMD ["/bin/bash"]
89
+ # Copy and set up firewall script
90
+ COPY init-firewall.sh /usr/local/bin/
91
+ USER root
92
+ RUN chmod +x /usr/local/bin/init-firewall.sh && \
93
+ echo "node ALL=(root) NOPASSWD: /usr/local/bin/init-firewall.sh" > /etc/sudoers.d/node-firewall && \
94
+ chmod 0440 /etc/sudoers.d/node-firewall
95
+ USER node
package/README.md CHANGED
@@ -1,150 +1,231 @@
1
1
  # SandboxBox
2
2
 
3
- **Zero-privilege container runner with Playwright support**
3
+ **Cross-platform container runner with Claude Code and Playwright support**
4
4
 
5
- Run containers without Docker, root privileges, or external dependencies. Just bubblewrap and Node.js.
5
+ Run your projects in isolated containers using Podman. Works on **Windows, macOS, and Linux**.
6
6
 
7
- ## 🚀 Quick Start
7
+ ## Installation
8
+
9
+ No installation required! Use with `npx`:
8
10
 
9
- ### One-Time Setup
10
11
  ```bash
11
- # Install bubblewrap (requires sudo ONCE)
12
- sudo apt-get install bubblewrap # Ubuntu/Debian
13
- sudo apk add bubblewrap # Alpine
12
+ npx sandboxbox build
13
+ npx sandboxbox run ./my-project
14
+ ```
15
+
16
+ ## Quick Start
14
17
 
15
- # Setup Alpine environment
16
- npx sandboxbox setup
18
+ ### 1. Install Podman (One-time)
19
+
20
+ **Windows:**
21
+ ```powershell
22
+ winget install RedHat.Podman
17
23
  ```
18
24
 
19
- ### Run Playwright Tests
25
+ **macOS:**
20
26
  ```bash
21
- # Test any project
22
- npx sandboxbox run ./my-project
27
+ brew install podman
28
+ podman machine init
29
+ podman machine start
30
+ ```
23
31
 
24
- # Quick test with sample Dockerfile
25
- npx sandboxbox quick-test ./my-app
32
+ **Linux:**
33
+ ```bash
34
+ sudo apt-get install podman # Ubuntu/Debian
35
+ sudo dnf install podman # Fedora
36
+ sudo apk add podman # Alpine
37
+ ```
26
38
 
27
- # Interactive shell
28
- npx sandboxbox shell ./my-project
39
+ ### 2. Build Container
40
+
41
+ ```bash
42
+ npx sandboxbox build
29
43
  ```
30
44
 
31
- ### Build from Dockerfile
45
+ This builds a container with:
46
+ - Node.js v22
47
+ - Claude Code CLI
48
+ - Playwright with all browser dependencies
49
+ - Git, npm, and essential build tools
50
+
51
+ ### 3. Run Your Project
52
+
32
53
  ```bash
33
- # Build container
34
- npx sandboxbox build ./Dockerfile
54
+ # Run with default shell
55
+ npx sandboxbox run ./my-project
35
56
 
36
- # Run the built container
37
- npx sandboxbox run ./project-directory
38
- ```
57
+ # Run custom command
58
+ npx sandboxbox run ./my-project "npm test"
59
+
60
+ # Run Claude Code
61
+ npx sandboxbox run ./my-project "claude --help"
39
62
 
40
- ## 📋 Commands
63
+ # Run Playwright tests
64
+ npx sandboxbox run ./my-project "npx playwright test"
65
+ ```
41
66
 
42
- | Command | Description |
43
- |---------|-------------|
44
- | `setup` | Set up Alpine Linux environment (one-time) |
45
- | `build <dockerfile>` | Build container from Dockerfile |
46
- | `run <project>` | Run Playwright tests in isolation |
47
- | `shell <project>` | Interactive shell in container |
48
- | `quick-test <project>` | Quick test with sample Dockerfile |
49
- | `version` | Show version information |
67
+ ### 4. Interactive Shell
50
68
 
51
- ## ⚡ Performance
69
+ ```bash
70
+ npx sandboxbox shell ./my-project
71
+ ```
52
72
 
53
- - **8ms startup** (37x faster than Docker)
54
- - **1MB memory overhead** (50x less than Docker)
55
- - **True isolation** with Linux namespaces
56
- - **Zero privileges** after bubblewrap installation
73
+ ## Features
57
74
 
58
- ## 🎯 What Works
75
+ ### 🌍 Cross-Platform
76
+ - **Windows** - Full support with Podman Desktop
77
+ - **macOS** - Works with Podman machine
78
+ - **Linux** - Native Podman support
59
79
 
60
- **Chromium testing** - Full Playwright support
61
- ✅ **Node.js projects** - Complete npm ecosystem
62
- **Filesystem isolation** - Separate container environment
63
- **Network access** - Full connectivity
64
- ✅ **Process isolation** - Separate PID namespace
80
+ ### 🔒 Isolation
81
+ - Complete container isolation
82
+ - Your host system stays clean
83
+ - Workspace mounted at `/workspace`
65
84
 
66
- ## ⚠️ Limitations
85
+ ### 🚀 Pre-installed Tools
86
+ - **Node.js v22**
87
+ - **Claude Code CLI** - AI-powered development
88
+ - **Playwright** - Browser automation with all dependencies
89
+ - **Git** - Version control
90
+ - **npm** - Package management
67
91
 
68
- **Firefox/WebKit** - Need glibc (use Ubuntu for these)
69
- **GPU acceleration** - Limited support
70
- ❌ **System packages** - Can't install with apt/yum
92
+ ### 📦 NPX-First Design
93
+ - No global installation needed
94
+ - Single command execution
95
+ - Works with any project directory
71
96
 
72
- ## 🔧 Alternative Usage
97
+ ## Commands
73
98
 
74
- ### Local Script
75
99
  ```bash
76
- # Using the wrapper script
77
- ./run.sh run ./my-project
100
+ # Build container from Dockerfile
101
+ npx sandboxbox build
102
+ npx sandboxbox build ./Dockerfile.custom
103
+
104
+ # Run project in container
105
+ npx sandboxbox run <project-dir> [command]
78
106
 
79
- # Direct Node.js execution
80
- node cli.js run ./my-project
107
+ # Interactive shell
108
+ npx sandboxbox shell <project-dir>
109
+
110
+ # Show version
111
+ npx sandboxbox version
81
112
  ```
82
113
 
83
- ### As npm dependency
84
- ```bash
85
- # Install in your project
86
- npm install sandboxbox
114
+ ## How It Works
87
115
 
88
- # Use in package.json scripts
89
- {
90
- "scripts": {
91
- "test:isolated": "sandboxbox run .",
92
- "test:container": "sandboxbox quick-test ."
93
- }
94
- }
116
+ 1. **Builds** a container image from the Dockerfile using Podman
117
+ 2. **Mounts** your project directory to `/workspace` in the container
118
+ 3. **Runs** your command in the isolated container environment
119
+ 4. **Removes** the container automatically when done
120
+
121
+ ```
122
+ Your Project Container
123
+ ./my-project ━━━━━> /workspace
124
+ (host) (isolated)
95
125
  ```
96
126
 
97
- ## 📖 Examples
127
+ ## Use Cases
128
+
129
+ ### Run Claude Code
130
+ ```bash
131
+ npx sandboxbox run ./my-app "claude --version"
132
+ npx sandboxbox run ./my-app "claude code review lib/"
133
+ ```
134
+
135
+ ### Run Playwright Tests
136
+ ```bash
137
+ npx sandboxbox run ./my-app "npx playwright test"
138
+ npx sandboxbox run ./my-app "npx playwright test --headed"
139
+ ```
98
140
 
99
- ### Basic Playwright Testing
141
+ ### Development Workflow
100
142
  ```bash
101
- # Create a simple project
102
- mkdir my-test && cd my-test
103
- npm init -y
104
- npm install playwright
143
+ # Build once
144
+ npx sandboxbox build
105
145
 
106
- # Create a test
107
- cat > test.spec.js << 'EOF'
108
- import { test, expect } from '@playwright/test';
146
+ # Interactive development
147
+ npx sandboxbox shell ./my-app
109
148
 
110
- test('basic test', async ({ page }) => {
111
- await page.goto('https://example.com');
112
- await expect(page).toHaveTitle(/Example/);
113
- });
114
- EOF
149
+ # Inside container:
150
+ npm install
151
+ npm test
152
+ git commit -am "Update"
153
+ exit
154
+ ```
115
155
 
116
- # Run in isolated container
117
- npx sandboxbox quick-test .
156
+ ### Run npm Scripts
157
+ ```bash
158
+ npx sandboxbox run ./my-app "npm run build"
159
+ npx sandboxbox run ./my-app "npm run lint"
160
+ npx sandboxbox run ./my-app "npm run test:e2e"
118
161
  ```
119
162
 
120
- ### Custom Dockerfile
163
+ ## Custom Dockerfile
164
+
165
+ Create your own `Dockerfile`:
166
+
121
167
  ```dockerfile
122
- # Dockerfile.custom
123
- FROM alpine
168
+ FROM node:22-alpine
169
+
170
+ # Install system dependencies
171
+ RUN apk add --no-cache git bash curl
124
172
 
125
- RUN apk add --no-cache nodejs npm curl
126
- WORKDIR /app
127
- COPY package*.json ./
128
- RUN npm install
129
- COPY . .
173
+ # Install global packages
174
+ RUN npm install -g @anthropic-ai/claude-code @playwright/test
130
175
 
131
- CMD ["npm", "start"]
176
+ # Install Playwright browsers
177
+ RUN npx playwright install --with-deps chromium
178
+
179
+ WORKDIR /workspace
180
+
181
+ CMD ["/bin/bash"]
132
182
  ```
133
183
 
184
+ Then build:
134
185
  ```bash
135
- # Build and run
136
- npx sandboxbox build Dockerfile.custom
137
- npx sandboxbox run .
186
+ npx sandboxbox build ./Dockerfile
187
+ ```
188
+
189
+ ## Requirements
190
+
191
+ - **Podman** (https://podman.io/getting-started/installation)
192
+ - **Node.js 16+** (for running npx)
193
+
194
+ ## Project Structure
195
+
196
+ ```
197
+ sandboxbox/
198
+ ├── cli.js # Main CLI - Podman integration
199
+ ├── Dockerfile # Container definition
200
+ ├── package.json # NPM package config
201
+ └── README.md # This file
138
202
  ```
139
203
 
140
- ## 🏗️ Architecture
204
+ ## Why Podman?
205
+
206
+ - ✅ **Cross-platform** - Works on Windows, macOS, Linux
207
+ - ✅ **Rootless** - No daemon, runs as regular user
208
+ - ✅ **Docker-compatible** - Uses OCI standard containers
209
+ - ✅ **Secure** - Better security model than Docker
210
+ - ✅ **Fast** - Lightweight and efficient
211
+
212
+ ## Differences from v1.x
213
+
214
+ **v1.x (bubblewrap):**
215
+ - Linux-only
216
+ - Required bubblewrap installation
217
+ - Direct process isolation
218
+
219
+ **v2.x (Podman):**
220
+ - Cross-platform (Windows/macOS/Linux)
221
+ - Uses Podman containers
222
+ - OCI-standard container images
223
+ - More portable and widely supported
224
+
225
+ ## License
141
226
 
142
- SandboxBox uses:
143
- - **Bubblewrap (bwrap)** - Linux namespace isolation
144
- - **Alpine Linux** - Lightweight base filesystem
145
- - **System Chromium** - Avoids glibc compatibility issues
146
- - **Xvfb** - Virtual display for headless testing
227
+ MIT
147
228
 
148
- ## 📄 License
229
+ ## Contributing
149
230
 
150
- MIT
231
+ Contributions welcome! This project focuses on cross-platform container execution with Claude Code and Playwright support using Podman.