feat(devcontainer): improve performance and reliability of devcontainer launch#119
feat(devcontainer): improve performance and reliability of devcontainer launch#119stewartadam wants to merge 11 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the devcontainer configuration to improve build performance and reliability, particularly for developers working behind corporate proxies with TLS inspection. The changes remove unused features (Python, Azure CLI), add volume mounts for better I/O performance, normalize the workspace path, and add support for corporate CA certificate injection and git identity configuration.
Key changes include:
- Removal of unused Python and Azure CLI features to speed up container builds
- Addition of volume mounts for node_modules and user config to improve performance
- Implementation of corporate CA certificate injection for TLS inspection compatibility
- Git config workaround to properly handle conditional includes in devcontainers
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
.gitignore |
Adds gitconfig export files used by devcontainer git identity workaround |
.gitattributes |
Defines line ending rules for Windows and Linux scripts (has duplicate entry) |
.dockerignore |
Excludes .git/ and node_modules/ from Docker build context |
.devcontainer/scripts/post-create.sh |
Adds volume ownership fixes, npm install, and CA cert injection logic |
.devcontainer/scripts/post-attach.sh |
New script implementing git identity configuration workaround |
.devcontainer/devcontainer.json |
Configures workspace mount, volumes, environment variables, lifecycle commands (has JSON syntax error) |
.devcontainer/README.md |
Updates documentation to reflect removed features and add TLS troubleshooting |
Comments suppressed due to low confidence (1)
.devcontainer/scripts/post-create.sh:44
- Security concern: The CA certificate injection feature copies all
.crtfiles from.devcontainer/to the system trust store without validation. Consider adding validation to:
- Verify the files are valid PEM-formatted certificates before copying
- Add a warning message when certificates are being added
- Document the security implications in comments
Example:
if compgen -G ".devcontainer/*.crt" > /dev/null; then
echo "WARNING: Adding custom CA certificates to system trust store"
# Validate certs before copying
for cert in .devcontainer/*.crt; do
if openssl x509 -in "$cert" -noout 2>/dev/null; then
sudo cp "$cert" /usr/local/share/ca-certificates/
else
echo "ERROR: Invalid certificate file: $cert"
exit 1
fi
done
sudo update-ca-certificates
fi if compgen -G ".devcontainer/*.crt" > /dev/null; then
sudo cp .devcontainer/*.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
fi
echo "Container's system CA certificates updated successfully"
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
.devcontainer/scripts/post-create.sh:42
- Consider adding validation to check if the
.crtfiles are valid PEM-formatted certificates before copying them to the system certificate store. Blindly copying arbitrary files with.crtextension could introduce security risks if the files are malformed or malicious. Add a basic validation check usingopenssl x509 -in "$file" -nooutbefore copying.
if compgen -G ".devcontainer/*.crt" > /dev/null; then
sudo cp .devcontainer/*.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| for conf in .gitconfig.global .gitconfig.local; do | ||
| if [[ -f "$conf" ]]; then | ||
| echo "*** Parsing ${conf##.gitconfig.} Git configuration export" | ||
| while IFS='=' read -r key value; do | ||
| local key value |
There was a problem hiding this comment.
The local keyword should be declared before the variable assignment in the while read loop. Move the local key value declaration outside and before the loop to avoid redeclaring on each iteration.
Suggested fix:
copy_user_gitconfig() {
local key value
for conf in .gitconfig.global .gitconfig.local; do
if [[ -f "$conf" ]]; then
echo "*** Parsing ${conf##.gitconfig.} Git configuration export"
while IFS='=' read -r key value; do
case "$key" in
user.name | user.email | user.signingkey | commit.gpgsign)
echo "Set Git config ${key}=${value}"
git config --global "$key" "$value"
;;
esac
done < "$conf"
rm -f "${conf}"
fi
done
}| for conf in .gitconfig.global .gitconfig.local; do | |
| if [[ -f "$conf" ]]; then | |
| echo "*** Parsing ${conf##.gitconfig.} Git configuration export" | |
| while IFS='=' read -r key value; do | |
| local key value | |
| local key value | |
| for conf in .gitconfig.global .gitconfig.local; do | |
| if [[ -f "$conf" ]]; then | |
| echo "*** Parsing ${conf##.gitconfig.} Git configuration export" | |
| while IFS='=' read -r key value; do |
|
@stewartadam - closing this for now. I'm going to take on some of the core performance improvements for the container but skip the CA integration as there's been some debate over if we should enable this. If you want to trim this down and pull the ca and SSL work, then we can take it .. let me know. |
|
@copilot please remove the TLS certificate workarounds from this PR |
|
@WilliamBerryiii removed the custom-ca workarounds from the PR, I don't have permissions to re-open so lmk if you prefer a new PR against this branch. |
Pull Request
Description
Captures learnings from recent customer projects to enhance the build speed and launch reliability of the dev container.
🚀 - Generated by Copilot
Related Issue(s)
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderchatmode and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/chatmodes/*.chatmode.md)Other:
.ps1,.sh,.py)Testing
Checklist
Required Checks
Required Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run lint:md-linksnpm run lint:psSecurity Considerations
Additional Notes