[WIP] MAINT: Optimize devcontainer Dockerfile#1437
Draft
spencrr wants to merge 1 commit intoAzure:mainfrom
Draft
[WIP] MAINT: Optimize devcontainer Dockerfile#1437spencrr wants to merge 1 commit intoAzure:mainfrom
devcontainer Dockerfile#1437spencrr wants to merge 1 commit intoAzure:mainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Optimizes the devcontainer Dockerfile to significantly improve build speed, reduce image size, and tighten permissions.
Key changes:
Build performance
--mount=type=cache) for allapt-getlayers instead ofapt-get clean && rm -rf /var/lib/apt/lists/*— cached packages persist across rebuilds, so subsequentdocker buildinvocations skip re-downloading unchanged packages. This is a Docker best practice for development images recommended by Copilot.uvviaCOPY --from=ghcr.io/astral-sh/uv:0.10.8multi-stage copy instead ofcurl | sh— avoids a network round-trip, shell pipe execution, and the extra cleanup of/root/.local/bin. Multi-stageCOPY --fromis a Docker best practice recommended by Copilot for installing standalone binaries.npm install -g npm@latest— the NodeSource setup script already installs a compatible npm version, and running a global npm self-upgrade adds build time and a mutable layer. Copilot flagged this as unnecessary.Image size
--no-install-recommendsto allapt-get installinvocations — Debian's "Recommends" packages are not required for runtime correctness and can add 100+ MB of unnecessary dependencies (e.g., X11 libs, man pages). This is a widely recognized Dockerfile best practice recommended by Copilot.apt-transport-https— this package was required on older Debian/Ubuntu versions (pre-Buster) to enable HTTPS in APT. Since Debian Bookworm, HTTPS support is built intoaptnatively, making this package a no-op. Copilot identified it as obsolete for the current base image.lsb-release— this was previously used to dynamically detect the distro codename for the Microsoft APT repo URL. Since the repo URL is now hardcoded tobookworm(matching the pinned base image),lsb-releaseis no longer needed. Copilot confirmed the removal is safe given the pinned base.Reproducibility
python:3.11-bookworminstead ofpython:3.11— the untagged variant can silently shift between Debian releases (e.g., Bookworm → Trixie) when Microsoft updates the base image, potentially breakingaptrepo URLs and package availability. Pinning to a specific distro release is a Copilot-recommended best practice for deterministic builds.DEBIAN_FRONTEND=noninteractiveas a globalENVinstead of inline per-command — prevents anyapt-getinvocation from prompting for interactive input (e.g., timezone or keyboard layout). Setting it once at the top is cleaner and avoids forgetting it on newRUNlines. This is a standard Dockerfile pattern recommended by Copilot.Security hardening
chmod 777→chmod 755for all cache directories (pip, pylance, venv, uv, mypy) —777grants world-read/write/execute, which is unnecessary in a single-user devcontainer wherevscodeowns these directories.755allows the owner full access and others read/execute only. Copilot flagged777as an overly permissive anti-pattern.Node.js
Git config
core.fsmonitor=true— this enables the built-in file system monitor for git status acceleration, but it can cause high CPU usage, stale index issues, and watchman/inotify conflicts inside containers where the filesystem (overlayfs, bind mounts) doesn't support efficient native watch events. Copilot recommended removing it for container environments.Tests and Documentation