|
| 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. |
0 commit comments