-
Notifications
You must be signed in to change notification settings - Fork 252
ADDED DEVCONTAINER #487
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
base: main
Are you sure you want to change the base?
ADDED DEVCONTAINER #487
Conversation
WalkthroughAdds a Dev Container configuration file defining a Python 3.10-based development container, VSCode extensions and settings, Docker socket mount, host resource requirements, and init/post-create commands to install build tools and Python dependencies via poetry. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.devcontainer/devcontainer.json (2)
16-17: Clarify or document GitHub Copilot extensions.The Copilot extensions are optional, paid features that require user authentication and a license. Consider adding a comment in the configuration or documentation to clarify that these are optional and that users without a license can remove them. Alternatively, if they are not core to team development, consider moving them to a user-level VS Code configuration rather than enforcing them in the shared devcontainer.
Verify that Copilot extensions are aligned with your team's development standards and licensing.
35-35: Refactor postCreateCommand into a dedicated script for better error handling and maintainability.The current
postCreateCommandcombines multiple setup steps (apt-get updates, package installations, pip installs, poetry install) into a single compound command. If any step fails silently or partially, subsequent steps may not execute as expected, leading to a broken development environment. Additionally, this is difficult to debug and maintain.Consider creating a dedicated setup script (e.g.,
.devcontainer/setup.sh) and calling it frompostCreateCommandinstead.Create
.devcontainer/setup.sh:#!/bin/bash set -e # Exit on first error # Update package manager apt-get update # Install system dependencies apt-get install -y build-essential zip binutils # Install Python packages with constraints pip install 'urllib3<2' pip install pyinstaller poetry # Install project dependencies poetry installThen update the devcontainer.json:
- "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install pyinstaller poetry && poetry install", + "postCreateCommand": "bash .devcontainer/setup.sh",Also add
.devcontainer/setup.shto version control.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.devcontainer/devcontainer.json(1 hunks)
🔇 Additional comments (3)
.devcontainer/devcontainer.json (3)
35-35: Clarify theurllib3<2version constraint.The postCreateCommand pins
urllib3to versions less than 2. Please document or clarify why this constraint is necessary (e.g., is it a known incompatibility with a transitive dependency, or a temporary workaround?). If this is a long-term constraint, consider documenting it in the project's dependency management (e.g.,pyproject.tomlorpoetry.lock).Confirm whether the
urllib3<2constraint is a permanent requirement or a temporary workaround.
3-3: Verify Python 3.10 is the correct minimum version.The devcontainer specifies Python 3.10. Confirm this aligns with the project's supported Python versions and any minimum version requirements documented in
pyproject.tomlor similar.Check the project's Python version requirements and confirm Python 3.10 is appropriate.
19-20: Remove JavaScript tooling extensions (ESLint, Jest).ESLint and Jest are JavaScript/TypeScript tools, but this is a Python project. These extensions appear to be unintended inclusions from a template or copy-paste error and should be removed to keep the environment focused.
"extensions": [ "ms-python.python", "ms-python.vscode-pylance", "ms-python.debugpy", "GitHub.copilot", "GitHub.copilot-chat", "EditorConfig.EditorConfig", - "dbaeumer.vscode-eslint", - "Orta.vscode-jest", "eamodio.gitlens" ],
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.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.devcontainer/devcontainer.json(1 hunks)
🔇 Additional comments (2)
.devcontainer/devcontainer.json (2)
34-34: Critical: poetry installation order is broken.Line 34 executes
poetry installbeforepip install poetry, which will fail since poetry is not yet installed. Reorder the commands to install poetry first, then runpoetry install.- "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install -r requirements.txt && pip install poetry && poetry install", + "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install poetry && poetry install",Likely an incorrect or invalid review comment.
34-34: The urllib3<2 constraint is necessary and justified by upstream dependencies—the review comment is incorrect.The constraint is driven by transitive dependency requirements, not an arbitrary limitation:
- prometrix explicitly requires
urllib3 = ">=1.26.18,<2.0.0"- botocore for Python <3.10 requires
urllib3 = ">=1.25.4,<1.27"The manual
pip install 'urllib3<2'line is redundant (since poetry.lock already pins urllib3==1.26.18 and poetry install will enforce it), but removing it would not allow poetry to relax the constraint—the poetry.lock file is locked to these versions specifically because upstream dependencies require them.Rather than removing the constraint or manual pip install, poetry is already managing the dependency correctly through its lock file. If urllib3 2.0 compatibility is desired in the future, upstream dependencies (especially prometrix) would need to release versions supporting urllib3 ≥2.0 first.
| "GitHub.copilot", | ||
| "GitHub.copilot-chat", |
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.
Minor: copilot-chat may assume unnecessary licensing.
Line 15–16 includes GitHub.copilot-chat along with GitHub.copilot. This assumes all developers have Copilot licenses. Consider removing copilot-chat or making it optional via a comment.
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json lines 15-16: the devcontainer currently lists
"GitHub.copilot-chat" alongside "GitHub.copilot", which presumes all developers
have the Copilot Chat license; remove "GitHub.copilot-chat" from the extensions
array or comment it out / add a note to make it optional so the devcontainer
doesn't force a licensed extension on every developer.
| "dbaeumer.vscode-eslint", | ||
| "Orta.vscode-jest", |
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.
Minor: ESLint and Jest extensions are not aligned with a Python project.
Lines 18–19 include dbaeumer.vscode-eslint and Orta.vscode-jest, which are JavaScript/TypeScript tooling. For a Python project, consider removing these unless the project explicitly includes JavaScript/TypeScript components.
"EditorConfig.EditorConfig",
- "dbaeumer.vscode-eslint",
- "Orta.vscode-jest",
"eamodio.gitlens"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "dbaeumer.vscode-eslint", | |
| "Orta.vscode-jest", |
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json around lines 18 to 19: the devcontainer lists
JavaScript/TypeScript extensions ("dbaeumer.vscode-eslint" and
"Orta.vscode-jest") that don't match a Python project; remove these two entries
from the extensions array (or replace them with Python-relevant extensions like
ms-python.python) so the devcontainer only installs tooling appropriate for the
repository.
| } | ||
| } | ||
| }, | ||
| "remoteUser": "root", |
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.
Major: Avoid running as root in development containers.
Running the container as root is a security anti-pattern and may not align with the project's development practices. Consider using a non-root user (e.g., vscode or developer). The base image mcr.microsoft.com/devcontainers/python:3.10 includes a vscode user by default.
- "remoteUser": "root",
+ "remoteUser": "vscode",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "remoteUser": "root", | |
| "remoteUser": "vscode", |
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json around line 28: the container is configured to
run as "root", which is a security anti-pattern; change "remoteUser" to a
non-root user provided by the base image (e.g., "vscode" or "developer") and
ensure any filesystem permissions or startup commands are adjusted accordingly
(update postCreateCommand or Dockerfile steps to chown workspace folders or
install tools for that user if needed) so the container runs as the non-root
user without breaking mounts or setup scripts.
| "cpus": 2, | ||
| "memory": "2gb" | ||
| }, | ||
| "initializeCommand": "rm -rf build && rm -rf dist", |
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.
Critical: initializeCommand runs on host machine and could delete build/dist directories.
The initializeCommand runs on the host before the container is spun up. Deleting build and dist from the host is destructive and unintended. Move this cleanup into postCreateCommand (inside the container) if needed, or remove it entirely.
- "initializeCommand": "rm -rf build && rm -rf dist",
+ "postCreateCommand": "set -e && apt-get update && apt-get install -y build-essential zip binutils && pip install poetry && poetry install && rm -rf build && rm -rf dist",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "initializeCommand": "rm -rf build && rm -rf dist", | |
| "postCreateCommand": "set -e && apt-get update && apt-get install -y build-essential zip binutils && pip install poetry && poetry install && rm -rf build && rm -rf dist", |
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json around line 33: the initializeCommand currently
runs on the host and performs destructive rm -rf build && rm -rf dist; move this
cleanup into postCreateCommand (which runs inside the container) or remove it
entirely to avoid deleting host files. Replace or remove the initializeCommand
entry and add a postCreateCommand that performs the cleanup inside the container
(or omit cleanup) so host directories are not affected.
| "memory": "2gb" | ||
| }, | ||
| "initializeCommand": "rm -rf build && rm -rf dist", | ||
| "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install -r requirements.txt && pip install poetry && poetry install", |
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.
Critical: Don't mix pip and poetry for dependency management.
Running both pip install -r requirements.txt and poetry install creates redundant and conflicting dependency resolution. Poetry should be the single source of truth. Remove the pip install -r requirements.txt line if using poetry.
If requirements.txt is needed for non-poetry workflows (e.g., CI/CD), consider using poetry export to generate it from poetry.lock rather than maintaining both manually.
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json around line 34: the postCreateCommand mixes pip
and Poetry by running "pip install -r requirements.txt" and then "poetry
install", causing redundant/conflicting dependency management; remove the "pip
install -r requirements.txt" step so Poetry is the single source of truth for
dependencies, and if a requirements.txt is still needed for other workflows,
replace the manual file with a generated one via "poetry export" during CI or
devcontainer setup.
Major: Add error handling to postCreateCommand chain.
The long command chain has no error handling. If any step fails (e.g., apt-get update times out), subsequent steps still execute, potentially leaving the container in an inconsistent state. Use set -e or ensure proper && chaining.
- "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install -r requirements.txt && pip install poetry && poetry install",
+ "postCreateCommand": "set -e && apt-get update && apt-get install -y build-essential zip binutils && pip install poetry && poetry install",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "postCreateCommand": "apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install -r requirements.txt && pip install poetry && poetry install", | |
| "postCreateCommand": "set -e && apt-get update && apt-get install -y build-essential zip binutils && pip install 'urllib3<2' && pip install -r requirements.txt && pip install poetry && poetry install", |
🤖 Prompt for AI Agents
.devcontainer/devcontainer.json lines 34-34: the postCreateCommand string runs
multiple steps without robust shell error handling; update it to ensure the
shell exits immediately on any failure (e.g., enable set -e and safer flags like
-u and pipefail) so later steps won't run after an earlier failure—wrap or
invoke the command in a shell that sets -euo pipefail (or at minimum set -e)
before executing the existing chain, so failures abort the entire post-create
sequence.
|
@RohanRusta21 please refrain from tagging random people like this. I don't really have anything to do with this project, just have a recent contribution to it. Just create a PR and trust the process... don't start by aggressively tagging people to try to get attention (unless maybe the people you tag is someone you've already talked to and there is an understanding that you should be notifying them). |
Hi ,
Enhanced project maintainability with .devcontainer (for VS Code Remote-Containers support). Ready-to-use configurations for faster, consistent development.
Image attached for reference :
Please review and feel free if any enhancement required :)
Thanks,
Rohan