Skip to content

Dev container is slow to load: post-create.sh takes several minutes to finish #35

@arnaudlh

Description

@arnaudlh

Problem

The dev container is slow to load. After creation, the postCreateCommand (bash .devcontainer/post-create.sh) takes a few minutes to finish, blocking productive use of the workspace.

Repro

  1. Open the repo in a fresh dev container (Codespaces or VS Code Dev Containers).
  2. Wait through container build + features install.
  3. Observe post-create.sh running for several minutes before the environment is usable.

Root cause analysis

.devcontainer/post-create.sh runs three relatively heavy installs sequentially on every container creation:

  1. Checkovpip install --user --only-binary :all: checkov — large package with many transitive deps.
  2. PSRule.Rules.AzureInstall-Module ... -Scope CurrentUser -Force — pulls a large module from the PowerShell Gallery.
  3. ARM-TTKgit clone --depth 1 https://github.com/Azure/arm-ttk.git — network clone every time.

All three steps run serially and re-execute on every container rebuild, because they live in postCreateCommand rather than being baked into the image or cached via onCreateCommand / prebuilds.

Suggested fixes

  • Move installs into the image via a Dockerfile.
  • Use onCreateCommand instead of postCreateCommand for heavy/static installs.
  • Enable Codespaces prebuilds.
  • Run installs in parallel (& + wait).
  • Cache / pin ARM-TTK and skip clone if already present.
  • Consider a devcontainer Feature for ARM-TTK / PSRule.

Acceptance criteria

  • Time from "container created" to "ready to use" is significantly reduced (target: <30s steady state).
  • All existing tools (Checkov, PSRule.Rules.Azure, ARM-TTK) remain available with equivalent versions/behavior.
  • post-create.sh (or its replacement) is idempotent

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions