Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions codegen.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
ARG TARGETPLATFORM=linux/amd64
FROM --platform=$TARGETPLATFORM ghcr.io/astral-sh/uv:python3.13-bookworm

# Set environment variables to prevent interactive prompts during installation
ENV NVM_DIR=/usr/local/nvm \
NODE_VERSION=22.14.0 \
DEBIAN_FRONTEND=noninteractive \
NODE_OPTIONS="--max-old-space-size=8192" \
PYTHONUNBUFFERED=1 \
COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
PYTHONPATH="/usr/local/lib/python3.13/site-packages" \
IS_SANDBOX=True

ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:/usr/local/nvm:/usr/local/bin:$PATH

ARG INVALIDATE_FILES_LAYER=1
# Copy configuration files and set permissions
COPY sshd_config /etc/ssh/sshd_config
COPY ssh_config /etc/ssh/ssh_config
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY start.sh /usr/local/bin/start.sh
COPY setup_ssh_user.sh /usr/local/bin/setup_ssh_user.sh
COPY setup_ssh_keys.sh /usr/local/bin/setup_ssh_keys.sh
COPY nginx.conf /etc/nginx/nginx.conf
COPY error.html /usr/share/nginx/html/error.html
COPY tmux_output_script.sh /usr/local/bin/tmux_output_script.sh

# Install dependencies and set up environment in a single layer
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" \
git \
curl \
fd-find \
gh \
lsof \
ripgrep \
openssh-server \
nginx-full \
fcgiwrap \
tmux \
nano \
vim \
supervisor \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p -m 755 /etc/apt/keyrings \
&& wget -nv -O- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& 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 \
# Set up environment variables and save it to /etc/profile.d/nvm.sh
&& echo "export NVM_DIR=\"$NVM_DIR\"" >> /etc/profile.d/nvm.sh \
&& echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> /etc/profile.d/nvm.sh \
&& echo "export PATH=\"$NVM_DIR/versions/node/$NODE_VERSION/bin:\$PATH\"" >> /etc/profile.d/nvm.sh \
&& echo "export NVM_BIN=\"$NVM_DIR/versions/node/$NODE_VERSION/bin\"" >> /etc/profile.d/nvm.sh \
&& echo "export NODE_VERSION=\"$NODE_VERSION\"" >> /etc/profile.d/nvm.sh \
&& echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /etc/profile.d/nvm.sh \
&& echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile.d/nvm.sh \
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile.d/nvm.sh \
&& echo "export COREPACK_ENABLE_DOWNLOAD_PROMPT=0" >> /etc/profile.d/nvm.sh \
&& echo "export PYTHONPATH=\"/usr/local/lib/python3.13/site-packages\"" >> /etc/profile.d/nvm.sh \
&& echo "export IS_SANDBOX=true" >> /etc/profile.d/nvm.sh \
&& echo "export NPM_CONFIG_YES=true" >> /etc/profile.d/nvm.sh \
&& echo "export PIP_NO_INPUT=1" >> /etc/profile.d/nvm.sh \
&& echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /etc/profile.d/nvm.sh \
&& chmod +x /etc/profile.d/nvm.sh \
# Run the SSH setup script
&& /usr/local/bin/setup_ssh_user.sh \
# Install nvm, Node.js, and code-server
&& mkdir -p $NVM_DIR \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm use $NODE_VERSION \
&& npm install -g yarn pnpm \
&& corepack enable \
&& corepack prepare yarn@stable --activate \
&& corepack prepare pnpm@latest --activate \
&& curl -fsSL https://raw.githubusercontent.com/coder/code-server/refs/tags/v4.99.1/install.sh | sh \
&& uv tool install uvicorn[standard]

ENTRYPOINT ["/usr/local/bin/start.sh"]
162 changes: 106 additions & 56 deletions e2b.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,78 +1,128 @@
# Custom E2B Dockerfile for Outline Development
# This Dockerfile creates a sandbox template optimized for Outline (Node.js project)

FROM e2bdev/code-interpreter:latest
ARG TARGETPLATFORM=linux/amd64
FROM --platform=$TARGETPLATFORM e2bdev/code-interpreter:latest

# Update package lists
RUN apt-get update
# Set environment variables to prevent interactive prompts during installation
ENV NVM_DIR=/home/user/.nvm \
NODE_VERSION=20.18.0 \
DEBIAN_FRONTEND=noninteractive \
NODE_OPTIONS="--max-old-space-size=8192" \
PYTHONUNBUFFERED=1 \
COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
PYTHONPATH="/usr/local/lib/python3.13/site-packages" \
IS_SANDBOX=True

# Install Node.js 18 (LTS)
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && \
apt-get install -y nodejs
ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:/root/.local/bin:/usr/local/nvm:/usr/local/bin:$PATH

# Install Yarn package manager
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y yarn
# Start as root for system-level installations
USER root

# Install essential development tools
RUN apt-get install -y \
# Install dependencies and set up environment in a single layer
RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" \
git \
curl \
fd-find \
gh \
lsof \
ripgrep \
openssh-server \
nginx-full \
fcgiwrap \
tmux \
nano \
vim \
supervisor \
netcat-openbsd \
build-essential \
python3 \
python3-pip \
make \
g++ \
git \
curl \
wget \
vim \
nano \
unzip \
htop \
tree

# Install global Node.js packages commonly used with Outline
RUN npm install -g \
npm@latest \
typescript \
ts-node \
nodemon \
prettier \
eslint

# Set up workspace directory
WORKDIR /workspace
tree \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p -m 755 /etc/apt/keyrings \
&& wget -nv -O- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& 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

# Create cache directories to speed up subsequent installs
RUN mkdir -p /tmp/yarn-cache /tmp/npm-cache
# Set up global environment variables and save to profile
RUN echo "export NVM_DIR=\"/home/user/.nvm\"" >> /etc/profile.d/nvm.sh \
&& echo "[ -s \"/home/user/.nvm/nvm.sh\" ] && . \"/home/user/.nvm/nvm.sh\"" >> /etc/profile.d/nvm.sh \
&& echo "export PATH=\"/home/user/.nvm/versions/node/$NODE_VERSION/bin:\$PATH\"" >> /etc/profile.d/nvm.sh \
&& echo "export NVM_BIN=\"/home/user/.nvm/versions/node/$NODE_VERSION/bin\"" >> /etc/profile.d/nvm.sh \
&& echo "export NODE_VERSION=\"$NODE_VERSION\"" >> /etc/profile.d/nvm.sh \
&& echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /etc/profile.d/nvm.sh \
&& echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile.d/nvm.sh \
&& echo "export PYTHONUNBUFFERED=1" >> /etc/profile.d/nvm.sh \
&& echo "export COREPACK_ENABLE_DOWNLOAD_PROMPT=0" >> /etc/profile.d/nvm.sh \
&& echo "export PYTHONPATH=\"/usr/local/lib/python3.13/site-packages\"" >> /etc/profile.d/nvm.sh \
&& echo "export IS_SANDBOX=true" >> /etc/profile.d/nvm.sh \
&& echo "export NPM_CONFIG_YES=true" >> /etc/profile.d/nvm.sh \
&& echo "export PIP_NO_INPUT=1" >> /etc/profile.d/nvm.sh \
&& echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /etc/profile.d/nvm.sh \
&& echo "export PATH=\"/root/.local/bin:\$PATH\"" >> /etc/profile.d/nvm.sh \
&& chmod +x /etc/profile.d/nvm.sh

# Set environment variables for development
ENV NODE_ENV=development
ENV YARN_CACHE_FOLDER=/tmp/yarn-cache
ENV NPM_CONFIG_CACHE=/tmp/npm-cache
ENV WORKSPACE=/workspace
# Install uv (Python package manager) and uvicorn as root
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
&& echo 'export PATH="/root/.local/bin:$PATH"' >> /etc/profile.d/nvm.sh \
&& export PATH="/root/.local/bin:$PATH" \
&& uv tool install uvicorn[standard]

# Ensure the user has proper permissions
RUN chown -R user:user /workspace /tmp/yarn-cache /tmp/npm-cache
# Create workspace directories and set permissions
RUN mkdir -p /home/user/workspace /home/user/projects /home/user/.nvm

# Switch to non-root user for security
USER user
# Install nvm, Node.js, and package managers (as root but in user directory)
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | NVM_DIR="/home/user/.nvm" bash \
&& export NVM_DIR="/home/user/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" \
&& nvm install $NODE_VERSION \
&& nvm use $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& npm install -g yarn@latest pnpm@latest \
&& echo "Node.js and package managers installed successfully"

# Create common project structure
RUN mkdir -p /workspace/projects
# Install global Node.js development tools
RUN export NVM_DIR="/home/user/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" \
&& npm install -g \
npm@latest \
typescript \
ts-node \
nodemon \
prettier \
eslint

# Set default working directory
WORKDIR /workspace
# Set up user bashrc for when E2B creates the user
RUN echo "export NVM_DIR=\"\$HOME/.nvm\"" >> /home/user/.bashrc \
&& echo "[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\"" >> /home/user/.bashrc \
&& echo "[ -s \"\$NVM_DIR/bash_completion\" ] && . \"\$NVM_DIR/bash_completion\"" >> /home/user/.bashrc \
&& echo "export PATH=\"/root/.local/bin:\$HOME/.local/bin:\$PATH\"" >> /home/user/.bashrc \
&& echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /home/user/.bashrc \
&& echo "export NPM_CONFIG_YES=true" >> /home/user/.bashrc \
&& echo "export PIP_NO_INPUT=1" >> /home/user/.bashrc \
&& echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /home/user/.bashrc \
&& echo 'alias ll="ls -la"' >> /home/user/.bashrc \
&& echo 'alias la="ls -la"' >> /home/user/.bashrc \
&& echo 'alias ..="cd .."' >> /home/user/.bashrc \
&& echo 'alias grep="grep --color=auto"' >> /home/user/.bashrc \
&& chmod -R 755 /home/user

# Add helpful aliases for development
RUN echo 'alias ll="ls -la"' >> ~/.bashrc && \
echo 'alias la="ls -la"' >> ~/.bashrc && \
echo 'alias ..="cd .."' >> ~/.bashrc && \
echo 'alias grep="grep --color=auto"' >> ~/.bashrc
# Set working directory
WORKDIR /home/user/workspace

# Display versions for verification
RUN echo "=== Environment Setup Complete ===" && \
node --version && \
npm --version && \
yarn --version && \
git --version && \
python3 --version
# Verify installation and display versions
RUN export NVM_DIR="/home/user/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" \
&& echo "=== E2B Codegen Environment Setup Complete ===" \
&& node --version \
&& npm --version \
&& yarn --version \
&& pnpm --version \
&& python3 --version \
&& echo "Environment ready for development!"
17 changes: 17 additions & 0 deletions e2b.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is a config for E2B sandbox template.
# You can use template ID (syvvs1ijpd1dovri71y5) or template name (codegen-dev-v2) to create a sandbox:

# Python SDK
# from e2b import Sandbox, AsyncSandbox
# sandbox = Sandbox("codegen-dev-v2") # Sync sandbox
# sandbox = await AsyncSandbox.create("codegen-dev-v2") # Async sandbox

# JS SDK
# import { Sandbox } from 'e2b'
# const sandbox = await Sandbox.create('codegen-dev-v2')

team_id = "97040773-f47a-4e5d-8350-fe47b06c3ecb"
start_cmd = "/root/.jupyter/start-up.sh"
dockerfile = "e2b.Dockerfile"
template_name = "codegen-dev-v2"
template_id = "syvvs1ijpd1dovri71y5"
Loading