Skip to content

Commit f044331

Browse files
committed
feat: update docs
1 parent b92f214 commit f044331

File tree

3 files changed

+183
-158
lines changed

3 files changed

+183
-158
lines changed

docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"pages": [
4141
"sandboxes/overview",
4242
"sandboxes/setup-commands",
43+
"sandboxes/base-image",
4344
"sandboxes/editor",
4445
"sandboxes/environment-variables",
4546
"sandboxes/web-preview"

docs/sandboxes/base-image.mdx

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: "Base Image"
3+
sidebarTitle: "Base Image"
4+
icon: "docker"
5+
---
6+
7+
Codegen sandboxes are built on a custom Docker image that provides a comprehensive development environment. The base image includes:
8+
9+
- **Python 3.13** (via `ghcr.io/astral-sh/uv:python3.13-bookworm`)
10+
- **Node.js 22.14.0** (managed via NVM)
11+
- **Essential development tools**: git, curl, ripgrep, fd-find, gh (GitHub CLI)
12+
- **Package managers**: uv, npm, yarn, pnpm
13+
- **Editors**: nano, vim
14+
- **System utilities**: tmux, supervisor, nginx
15+
16+
## Dockerfile
17+
18+
```dockerfile
19+
ARG TARGETPLATFORM=linux/amd64
20+
FROM --platform=$TARGETPLATFORM ghcr.io/astral-sh/uv:python3.13-bookworm
21+
22+
# Set environment variables to prevent interactive prompts during installation
23+
ENV NVM_DIR=/usr/local/nvm \
24+
NODE_VERSION=22.14.0 \
25+
DEBIAN_FRONTEND=noninteractive \
26+
NODE_OPTIONS="--max-old-space-size=8192" \
27+
PYTHONUNBUFFERED=1 \
28+
COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
29+
PYTHONPATH="/usr/local/lib/python3.13/site-packages" \
30+
IS_SANDBOX=True
31+
32+
ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:/usr/local/nvm:/usr/local/bin:$PATH
33+
34+
ARG INVALIDATE_FILES_LAYER=1
35+
# Copy configuration files and set permissions
36+
COPY sshd_config /etc/ssh/sshd_config
37+
COPY ssh_config /etc/ssh/ssh_config
38+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
39+
COPY start.sh /usr/local/bin/start.sh
40+
COPY setup_ssh_user.sh /usr/local/bin/setup_ssh_user.sh
41+
COPY setup_ssh_keys.sh /usr/local/bin/setup_ssh_keys.sh
42+
COPY nginx.conf /etc/nginx/nginx.conf
43+
COPY error.html /usr/share/nginx/html/error.html
44+
COPY tmux_output_script.sh /usr/local/bin/tmux_output_script.sh
45+
46+
# Install dependencies and set up environment in a single layer
47+
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" \
48+
git \
49+
curl \
50+
fd-find \
51+
gh \
52+
lsof \
53+
ripgrep \
54+
openssh-server \
55+
nginx-full \
56+
fcgiwrap \
57+
tmux \
58+
nano \
59+
vim \
60+
supervisor \
61+
netcat-openbsd \
62+
&& rm -rf /var/lib/apt/lists/* \
63+
&& mkdir -p -m 755 /etc/apt/keyrings \
64+
&& wget -nv -O- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
65+
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
66+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
67+
# Set up environment variables and save it to /etc/profile.d/nvm.sh
68+
&& echo "export NVM_DIR=\"$NVM_DIR\"" >> /etc/profile.d/nvm.sh \
69+
&& echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> /etc/profile.d/nvm.sh \
70+
&& echo "export PATH=\"$NVM_DIR/versions/node/$NODE_VERSION/bin:\$PATH\"" >> /etc/profile.d/nvm.sh \
71+
&& echo "export NVM_BIN=\"$NVM_DIR/versions/node/$NODE_VERSION/bin\"" >> /etc/profile.d/nvm.sh \
72+
&& echo "export NODE_VERSION=\"$NODE_VERSION\"" >> /etc/profile.d/nvm.sh \
73+
&& echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /etc/profile.d/nvm.sh \
74+
&& echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile.d/nvm.sh \
75+
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile.d/nvm.sh \
76+
&& echo "export COREPACK_ENABLE_DOWNLOAD_PROMPT=0" >> /etc/profile.d/nvm.sh \
77+
&& echo "export PYTHONPATH=\"/usr/local/lib/python3.13/site-packages\"" >> /etc/profile.d/nvm.sh \
78+
&& echo "export IS_SANDBOX=true" >> /etc/profile.d/nvm.sh \
79+
&& echo "export NPM_CONFIG_YES=true" >> /etc/profile.d/nvm.sh \
80+
&& echo "export PIP_NO_INPUT=1" >> /etc/profile.d/nvm.sh \
81+
&& echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /etc/profile.d/nvm.sh \
82+
&& chmod +x /etc/profile.d/nvm.sh \
83+
# Run the SSH setup script
84+
&& /usr/local/bin/setup_ssh_user.sh \
85+
# Install nvm, Node.js, and code-server
86+
&& mkdir -p $NVM_DIR \
87+
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
88+
&& . $NVM_DIR/nvm.sh \
89+
&& nvm install $NODE_VERSION \
90+
&& nvm use $NODE_VERSION \
91+
&& npm install -g yarn pnpm \
92+
&& corepack enable \
93+
&& corepack prepare yarn@stable --activate \
94+
&& corepack prepare pnpm@latest --activate \
95+
&& curl -fsSL https://raw.githubusercontent.com/coder/code-server/refs/tags/v4.99.1/install.sh | sh \
96+
&& uv tool install uvicorn[standard]
97+
98+
ENTRYPOINT ["/usr/local/bin/start.sh"]
99+
```
100+
101+
## Key Features
102+
103+
### Multi-Language Support
104+
The base image supports both Python and Node.js development out of the box, making it suitable for full-stack applications and polyglot projects.
105+
106+
### Development Tools
107+
Essential development tools are pre-installed, including:
108+
- **Git** for version control
109+
- **GitHub CLI** for GitHub integration
110+
- **ripgrep** and **fd-find** for fast file searching
111+
- **tmux** for terminal multiplexing
112+
- **nginx** for web server capabilities
113+
114+
### Package Managers
115+
Multiple package managers are available:
116+
- **uv** for Python package management
117+
- **npm**, **yarn**, and **pnpm** for Node.js packages
118+
- **corepack** for managing package manager versions
119+
120+
### SSH and Remote Access
121+
The image includes SSH server configuration for remote access and development, with proper user setup and key management.

docs/sandboxes/setup-commands.mdx

Lines changed: 61 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -13,109 +13,65 @@ Codegen lets you configure custom setup commands that run once when initializing
1313

1414
## Base Image
1515

16-
Codegen sandboxes are built on a custom Docker image that provides a comprehensive development environment. The base image includes:
17-
18-
- **Python 3.13** (via `ghcr.io/astral-sh/uv:python3.13-bookworm`)
19-
- **Node.js 22.14.0** (managed via NVM)
20-
- **Essential development tools**: git, curl, ripgrep, fd-find, gh (GitHub CLI)
21-
- **Package managers**: uv, npm, yarn, pnpm
22-
- **Editors**: nano, vim
23-
- **System utilities**: tmux, supervisor, nginx
24-
25-
<details>
26-
<summary>View the complete Dockerfile</summary>
27-
28-
```dockerfile
29-
ARG TARGETPLATFORM=linux/amd64
30-
31-
FROM --platform=$TARGETPLATFORM ghcr.io/astral-sh/uv:python3.13-bookworm
32-
33-
# Set environment variables to prevent interactive prompts during installation
34-
ENV NVM_DIR=/usr/local/nvm \
35-
NODE_VERSION=22.14.0 \
36-
DEBIAN_FRONTEND=noninteractive \
37-
NODE_OPTIONS="--max-old-space-size=8192" \
38-
PYTHONUNBUFFERED=1 \
39-
COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
40-
PYTHONPATH="/usr/local/lib/python3.13/site-packages" \
41-
IS_SANDBOX=True
42-
43-
ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:/usr/local/nvm:/usr/local/bin:$PATH
44-
45-
ARG INVALIDATE_FILES_LAYER=1
46-
# Copy configuration files and set permissions
47-
COPY sshd_config /etc/ssh/sshd_config
48-
COPY ssh_config /etc/ssh/ssh_config
49-
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
50-
COPY start.sh /usr/local/bin/start.sh
51-
COPY setup_ssh_user.sh /usr/local/bin/setup_ssh_user.sh
52-
COPY setup_ssh_keys.sh /usr/local/bin/setup_ssh_keys.sh
53-
COPY nginx.conf /etc/nginx/nginx.conf
54-
COPY error.html /usr/share/nginx/html/error.html
55-
COPY tmux_output_script.sh /usr/local/bin/tmux_output_script.sh
56-
57-
# Install dependencies and set up environment in a single layer
58-
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" \
59-
git \
60-
curl \
61-
fd-find \
62-
gh \
63-
lsof \
64-
ripgrep \
65-
openssh-server \
66-
nginx-full \
67-
fcgiwrap \
68-
tmux \
69-
nano \
70-
vim \
71-
supervisor \
72-
netcat-openbsd \
73-
&& rm -rf /var/lib/apt/lists/* \
74-
&& mkdir -p -m 755 /etc/apt/keyrings \
75-
&& wget -nv -O- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
76-
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
77-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
78-
# Set up environment variables and save it to /etc/profile.d/nvm.sh
79-
&& echo "export NVM_DIR=\"$NVM_DIR\"" >> /etc/profile.d/nvm.sh \
80-
&& echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> /etc/profile.d/nvm.sh \
81-
&& echo "export PATH=\"$NVM_DIR/versions/node/$NODE_VERSION/bin:\$PATH\"" >> /etc/profile.d/nvm.sh \
82-
&& echo "export NVM_BIN=\"$NVM_DIR/versions/node/$NODE_VERSION/bin\"" >> /etc/profile.d/nvm.sh \
83-
&& echo "export NODE_VERSION=\"$NODE_VERSION\"" >> /etc/profile.d/nvm.sh \
84-
&& echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /etc/profile.d/nvm.sh \
85-
&& echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile.d/nvm.sh \
86-
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile.d/nvm.sh \
87-
&& echo "export COREPACK_ENABLE_DOWNLOAD_PROMPT=0" >> /etc/profile.d/nvm.sh \
88-
&& echo "export PYTHONPATH=\"/usr/local/lib/python3.13/site-packages\"" >> /etc/profile.d/nvm.sh \
89-
&& echo "export IS_SANDBOX=true" >> /etc/profile.d/nvm.sh \
90-
&& echo "export NPM_CONFIG_YES=true" >> /etc/profile.d/nvm.sh \
91-
&& echo "export PIP_NO_INPUT=1" >> /etc/profile.d/nvm.sh \
92-
&& echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /etc/profile.d/nvm.sh \
93-
&& chmod +x /etc/profile.d/nvm.sh \
94-
# Run the SSH setup script
95-
&& /usr/local/bin/setup_ssh_user.sh \
96-
# Install nvm, Node.js, and code-server
97-
&& mkdir -p $NVM_DIR \
98-
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
99-
&& . $NVM_DIR/nvm.sh \
100-
&& nvm install $NODE_VERSION \
101-
&& nvm use $NODE_VERSION \
102-
&& npm install -g yarn pnpm \
103-
&& corepack enable \
104-
&& corepack prepare yarn@stable --activate \
105-
&& corepack prepare pnpm@latest --activate \
106-
&& curl -fsSL https://raw.githubusercontent.com/coder/code-server/refs/tags/v4.99.1/install.sh | sh \
107-
&& uv tool install uvicorn[standard]
108-
109-
ENTRYPOINT ["/usr/local/bin/start.sh"]
16+
Codegen sandboxes are built on a custom Docker image that provides a comprehensive development environment. For detailed information about the base image, including the complete Dockerfile and available tools, see the [Base Image](/sandboxes/base-image) documentation.
17+
18+
## Accessing Setup Commands
19+
20+
To configure setup commands for a repository:
21+
22+
1. Navigate to [codegen.com/repos](https://codegen.com/repos).
23+
2. Click on the desired repository from the list.
24+
3. You will be taken to the repository's settings page. The setup commands can be found at a URL similar to `https://www.codegen.com/repos/{arepo_name}/setup-commands`
25+
26+
<Frame caption="Set setup commands at codegen.com/repos">
27+
<img src="/images/setup-commands-ui.png" alt="Setup Commands UI" />
28+
</Frame>
29+
30+
## How it Works
31+
32+
Enter your desired setup commands in the provided text area, with one command per line. These commands will be executed in sequence within the sandbox environment.
33+
34+
For example, you might want to:
35+
36+
- Switch to a specific Node.js version.
37+
- Install project dependencies.
38+
- Run any necessary build steps or pre-compilation tasks.
39+
40+
After the commands are executed successfully, Codegen takes a snapshot of the sandbox's file system. This snapshot then serves as the base environment for future agent interactions with this repository, meaning your setup commands don't need to be re-run every time, saving time and ensuring consistency.
41+
42+
## Common Examples
43+
44+
Here are a few common use cases for setup commands:
45+
46+
```bash
47+
# Switch to Node.js version 20
48+
nvm use 20
49+
50+
# Install npm dependencies
51+
npm install
11052
```
11153

112-
</details>
54+
```bash
55+
# Setup with specific Python version for compatibility
56+
pyenv install 3.12.0
57+
pyenv local 3.12.0
58+
python -m venv venv
59+
source venv/bin/activate
60+
pip install -r requirements.txt
61+
```
62+
63+
```bash
64+
# Or a combination of commands
65+
nvm use 18
66+
npm ci
67+
npm run build
68+
```
11369

114-
## Working with Different Python Versions
70+
### Working with Different Python Versions
11571

11672
The sandbox comes with Python 3.13 by default, but some packages may not yet be compatible with this version. Here are strategies for handling different Python versions:
11773

118-
### Using pyenv for Multiple Python Versions
74+
#### Using pyenv for Multiple Python Versions
11975

12076
If you need to work with a different Python version, you can install and use `pyenv`:
12177

@@ -142,23 +98,22 @@ source venv/bin/activate
14298
pip install -r requirements.txt
14399
```
144100

145-
### Using uv with Specific Python Versions
101+
#### Using uv with Specific Python Versions
146102

147103
The `uv` package manager (already installed) can also manage Python versions:
148104

149105
```bash
150-
# Install a specific Python version with uv
151-
uv python install 3.12
106+
# Install Python 3.12 and create a virtual environment
107+
uv venv --python=3.12
152108

153-
# Create a project with a specific Python version
154-
uv init --python 3.12 my_project
155-
cd my_project
109+
# Activate the virtual environment
110+
source .venv/bin/activate
156111

157-
# Install dependencies with the specified Python version
158-
uv add your-package-name
112+
# Install dependencies
113+
uv pip install -r requirements.txt --refresh --upgrade
159114
```
160115

161-
### Virtual Environment Best Practices
116+
#### Virtual Environment Best Practices
162117

163118
When working with packages that require older Python versions:
164119

@@ -181,58 +136,6 @@ deactivate
181136
Remember to activate your virtual environment in your setup commands if you need specific Python versions for your project dependencies.
182137
</Warning>
183138

184-
## Accessing Setup Commands
185-
186-
To configure setup commands for a repository:
187-
188-
1. Navigate to [codegen.com/repos](https://codegen.com/repos).
189-
2. Click on the desired repository from the list.
190-
3. You will be taken to the repository's settings page. The setup commands can be found at a URL similar to `https://codegen.com/{your_org}/{repo_name}/settings/setup-commands` (the exact URL structure might vary slightly, look for a "Setup Commands" or "Sandbox Configuration" section).
191-
192-
<Frame caption="Set setup commands at codegen.com/repos">
193-
<img src="/images/setup-commands-ui.png" alt="Setup Commands UI" />
194-
</Frame>
195-
196-
## How it Works
197-
198-
Enter your desired setup commands in the provided text area, with one command per line. These commands will be executed in sequence within the sandbox environment.
199-
200-
For example, you might want to:
201-
202-
- Switch to a specific Node.js version.
203-
- Install project dependencies.
204-
- Run any necessary build steps or pre-compilation tasks.
205-
206-
After the commands are executed successfully, Codegen takes a snapshot of the sandbox's file system. This snapshot then serves as the base environment for future agent interactions with this repository, meaning your setup commands don't need to be re-run every time, saving time and ensuring consistency.
207-
208-
## Common Examples
209-
210-
Here are a few common use cases for setup commands:
211-
212-
```bash
213-
# Switch to Node.js version 20
214-
nvm use 20
215-
216-
# Install npm dependencies
217-
npm install
218-
```
219-
220-
```bash
221-
# Setup with specific Python version for compatibility
222-
pyenv install 3.12.0
223-
pyenv local 3.12.0
224-
python -m venv venv
225-
source venv/bin/activate
226-
pip install -r requirements.txt
227-
```
228-
229-
```bash
230-
# Or a combination of commands
231-
nvm use 18
232-
npm ci
233-
npm run build
234-
```
235-
236139
<Note>
237140
Ensure your setup commands are non-interactive and can run to completion
238141
without user input.

0 commit comments

Comments
 (0)