00003 — Container Build

By Engineering Team•November 29, 2026•5 min read

This page follows the purple path of 00001 — Workspace Topology: how the policy and tools reach a dev container, and why the assistant cannot change them afterwards. Requirement IDs refer to SR-AI-001. The engine guard and the deployer user are specified in SR-INFRA-010.

Every container is built the same way from one shared script, .devcontainer/shared/post-create.sh. It runs once, when the container is created or rebuilt, from the container’s postCreateCommand.

Container build: devcontainer.json runs post-create; as vscode with sudo, steps 1 to 4 clone the workspace and install git-lfs, OpenTofu, the 1Password CLI and Claude Code; as root before hardening, steps 5 to 9 install graphify, the commit scan, the managed policy and tofu-guard, then create the deployer user and remove sudo; every start then runs sync-projects


1. The steps

Step Script Runs as Installs If it fails
1. Clone the workspace repo postCreateCommand vscode The workspace repository into the container’s volume Build fails
2. git-lfs, OpenTofu post-create.sh vscode with sudo git-lfs filters, the OpenTofu engine Build fails
3. 1Password CLI install-op.sh vscode with sudo The op CLI from 1Password’s signed repository, for op run only Build fails
4. Claude Code post-create.sh vscode The assistant Build fails
5. graphify install-graphify.sh root /usr/local/bin/graphify, pinned to the skill’s version (SR-F-12) Build continues. The script reports why
6. Commit scan install-commit-scan.sh root gitleaks, a root-owned pre-commit hook in /usr/local/share/git-hooks/, and git’s system hooks path (SR-F-16) Build continues. Commits are refused until gitleaks is present
6a. draw.io install-drawio.sh root Only in a container that works on the documentation site: the draw.io desktop app (pinned, checksum-verified) and xvfb, so diagram pages export inside the container. Other containers skip it Build continues. The export script reports draw.io missing
7. Managed policy install-claude-policy.sh root /etc/claude-code/: the managed settings, hook copies, the recorded root and the claude shell function (SR-F-02, SR-F-09) Build fails, for example if a guard hook is missing or a hook would run a workspace file
8. tofu-guard install-tofu-guard.sh root /usr/local/bin/tofu-guard, the provider allowlist and the engine configuration Build fails
9. Harden harden-user.sh root The deployer user, then removes sudo from vscode Build fails if vscode still has sudo

2. Why the order matters

  • Root steps come before hardening. Steps 5 to 8 need root. Step 9 removes vscode’s sudo, so nothing after it could write to a root-owned path. From then on, the assistant, which runs as vscode, cannot change any of the files installed in steps 5 to 8 (SR-F-10).
  • Navigation and scanning never stop the build. If step 5 or 6 stopped the script, step 9 would never run and vscode would keep sudo. A missing tool there is safer than a container that was never hardened. The commit hook fails closed instead: it refuses commits until gitleaks is present.
  • Security steps do stop the build. If the policy, the engine guard or the hardening cannot be installed correctly, the container must not be used. A failed build is visible and is rebuilt.

3. Every start

After the build, each container start runs sync-projects.sh as vscode. It pulls the workspace and clones or pulls only the project repositories this container needs. It cannot touch anything installed in steps 5 to 9.

4. How a change reaches a container

The installed copies are what run. Their sources in the workspace repository can be edited, but an edit changes nothing in a running container. A change reaches it in four steps:

  1. The change is reviewed and merged to main in the workspace repository.
  2. It is pulled on the host, where VS Code reads devcontainer.json.
  3. It is pulled inside the container’s volume, where the post-create scripts run from.
  4. The container is rebuilt with Rebuild Container. The volume and workspace are kept.

5. Checking a rebuilt container

Check Expect
cat /etc/claude-code/workspace The workspace root
type claude The shell function
/hooks in Claude Code Only managed hooks: start-guard, env-guard, scope-guard, graphify hook-guard
command -v graphify /usr/local/bin/graphify
git config --system core.hooksPath /usr/local/share/git-hooks
sudo -n true as vscode Refused