Skip to content

Speed up devcontainer creation by parallelizing tool installs and moving them into the prebuild#36

Merged
sendtoshailesh merged 1 commit into
Azure:mainfrom
arnaudlh:fix/issue-35-devcontainer-speedup
Apr 28, 2026
Merged

Speed up devcontainer creation by parallelizing tool installs and moving them into the prebuild#36
sendtoshailesh merged 1 commit into
Azure:mainfrom
arnaudlh:fix/issue-35-devcontainer-speedup

Conversation

@arnaudlh
Copy link
Copy Markdown
Member

Container creation was slow because post-create.sh ran three sequential installs (Checkov, PSRule.Rules.Azure, arm-ttk) on every create, outside the prebuild.

Changes

  • devcontainer.json: switch postCreateCommandonCreateCommand so the work is captured by Codespaces prebuilds and doesn't re-run on each create.
  • post-create.sh: run the three independent installs in parallel; wall time ≈ slowest step instead of the sum.
  • Faster flags: pwsh -NoProfile, Install-Module -AcceptLicense -SkipPublisherCheck; pip --no-compile --disable-pip-version-check; git clone --single-branch --filter=blob:none.
  • Idempotent: skip steps when checkov is on PATH, PSRule.Rules.Azure is listed, arm-ttk.psd1 exists, or the profile import line is already present — re-runs (rebuild on existing volume) are near-instant.
  • Failure attribution: each background job logs to its own file; on failure the script reports which install failed and its exit code.
pids[checkov]=$!
pids[psrule]=$!
pids[armttk]=$!
for name in "${!pids[@]}"; do
  if ! wait "${pids[$name]}"; then
    echo "==> '$name' install failed with exit code $?" >&2
    status=1
  fi
done

Fixes #35

Container creation was slow because post-create.sh ran three sequential
installs (Checkov, PSRule.Rules.Azure, arm-ttk) on every create, outside
the prebuild.

- devcontainer.json: switch postCreateCommand -> onCreateCommand so the
  work is captured by Codespaces prebuilds and doesn't re-run on each
  create.
- post-create.sh: run the three independent installs in parallel; wall
  time is roughly the slowest step instead of the sum.
- Faster flags: pwsh -NoProfile, Install-Module -AcceptLicense
  -SkipPublisherCheck; pip --no-compile --disable-pip-version-check;
  git clone --single-branch --filter=blob:none.
- Idempotent: skip steps when checkov is on PATH, PSRule.Rules.Azure is
  listed, arm-ttk.psd1 exists, or the profile import line is already
  present - re-runs (rebuild on existing volume) are near-instant.
- Failure attribution: each background job logs to its own file; on
  failure the script reports which install failed and its exit code.

Fixes Azure#35
@arnaudlh arnaudlh self-assigned this Apr 27, 2026
@arnaudlh arnaudlh added the enhancement New feature or request label Apr 27, 2026
@arnaudlh arnaudlh requested review from sendtoshailesh and suuus and removed request for suuus April 27, 2026 05:07
@sendtoshailesh sendtoshailesh merged commit 330ed83 into Azure:main Apr 28, 2026
1 check passed
@arnaudlh arnaudlh added this to the v0.0.1 milestone May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants