forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Add devcontainer configuration for consistent development environment #8979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+107
−0
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # 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 [email protected] --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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "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 config set store-dir /pnpm/store && 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 root node_modules as volume for better performance | ||
| "source=node-modules,target=/workspace/node_modules,type=volume" | ||
| ], | ||
|
|
||
| // Environment variables | ||
| "containerEnv": { | ||
| "PNPM_HOME": "/pnpm" | ||
| }, | ||
|
|
||
| // Run as non-root user | ||
| "remoteUser": "node", | ||
|
|
||
| // Uncomment to connect as root instead | ||
| // "remoteUser": "root", | ||
|
|
||
| // Additional options | ||
| "updateRemoteUserUID": true, | ||
| "shutdownAction": "stopContainer" | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node_modules mount path is incorrect. Dev Containers mount the workspace to
/workspaces/<repo-name>by default, not/workspace. This mount will target an empty directory and won't provide the intended performance benefit. Use${containerWorkspaceFolder}/node_modulesinstead to automatically resolve to the correct workspace path (/workspaces/Roo-Code/node_modules).