feat: add devcontainer configuration for consistent development environment

- Add Dockerfile with Node 20.19.2 and pnpm 10.8.1
- Configure devcontainer.json with VS Code extensions
- Set up pnpm cache mounts for better performance
- Add postCreateCommand for automatic dependency installation
- Include GitHub CLI and Git features

Closes #8978
This commit is contained in:
Roo Code 2025-11-02 11:23:00 +00:00
parent ca10cba3c4
commit 62e5d4de63
2 changed files with 113 additions and 0 deletions

40
.devcontainer/Dockerfile Normal file
View file

@ -0,0 +1,40 @@
# Use the official Node.js image as base
FROM node:20.19.2-bookworm-slim
# Install basic development tools
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
ca-certificates \
gnupg \
lsb-release \
# Clean up apt cache to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Install pnpm globally with the exact version from package.json
RUN corepack enable && corepack prepare pnpm@10.8.1 --activate
# Set pnpm store directory for better caching
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Create a non-root user for development
ARG USERNAME=node
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Ensure the node user has the correct UID/GID
RUN groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chown -R $USER_UID:$USER_GID /home/$USERNAME
# Create pnpm directories with correct permissions
RUN mkdir -p /pnpm /workspace \
&& chown -R $USERNAME:$USERNAME /pnpm /workspace
# Switch to non-root user
USER $USERNAME
# Set the working directory
WORKDIR /workspace

View file

@ -0,0 +1,73 @@
{
"name": "Roo Code Dev Container",
"dockerFile": "Dockerfile",
// Features to add to the dev container
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Configure tool-specific properties
"customizations": {
"vscode": {
// Add the extensions from .vscode/extensions.json
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"csstools.postcss",
"bradlc.vscode-tailwindcss",
"connor4312.esbuild-problem-matchers",
"yoavbls.pretty-ts-errors"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash",
"icon": "terminal-bash"
}
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"typescript.tsdk": "node_modules/typescript/lib"
}
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally
"forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created
"postCreateCommand": "pnpm install --frozen-lockfile",
// Use 'postStartCommand' to run commands after the container starts
"postStartCommand": "echo '🎉 Dev container is ready!'",
// Configure mounts for better performance and caching
"mounts": [
// Mount pnpm store as a volume for caching
"source=pnpm-store,target=/pnpm,type=volume",
// Mount node_modules as volumes for better performance
"source=node-modules,target=/workspace/node_modules,type=volume",
"source=src-node-modules,target=/workspace/src/node_modules,type=volume",
"source=webview-ui-node-modules,target=/workspace/webview-ui/node_modules,type=volume"
],
// Environment variables
"containerEnv": {
"PNPM_HOME": "/pnpm",
"PATH": "/pnpm:${localEnv:PATH}"
},
// Run as non-root user
"remoteUser": "node",
// Uncomment to connect as root instead
// "remoteUser": "root",
// Additional options
"updateRemoteUserUID": true,
"shutdownAction": "stopContainer"
}