Skip to content

feat(docker): bundle the Azure CLI so the Azure tool works in the image - #165

Open
bartsdev wants to merge 4 commits into
mainfrom
update-docker-image
Open

bartsdev wants to merge 4 commits into
mainfrom
update-docker-image

Conversation

@bartsdev

@bartsdev bartsdev commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Lands #98 on main. #98 merged into #97's branch after #97 had been squash-merged, so its change never reached main. This branch now differs from main only by #98 and by a smaller way of installing the Azure CLI.

Summary

The image bundles the Azure CLI, so localstack-azure-client works from Docker instead of answering that az is missing.

Installing az is not enough by itself. Inside the container, every *.localhost.localstack.cloud name resolves to 127.0.0.1, which is the container itself, and the emulator gives each storage account its own host (<account>.blob.core.azure.localhost.localstack.cloud). So the server forwards its loopback gateway port to LocalStack:

sequenceDiagram
    participant az as az (in MCP container)
    participant fwd as 127.0.0.1:4566 forwarder
    participant LS as LocalStack (host.docker.internal:4566)
    az->>fwd: TLS to acct.blob.core.azure.localhost.localstack.cloud
    fwd->>LS: raw TCP pipe (SNI and cert unchanged)
    LS-->>az: response
Loading
 src/cli/index.ts  (default: start server)
   exitWhenClientDisconnects()
+  forwardLoopbackGateway()   # only in a container (/.dockerenv) with a non-local LOCALSTACK_HOSTNAME
   require("./stdio.js")

The Azure CLI comes from PyPI through a uv project, like SAM and Snowflake, not from Microsoft's apt package as in #98:

 docker/tools/
+├── azure/            # pyproject.toml + uv.lock: azure-cli==2.93.0 (Dependabot, 7-day cooldown)
 ├── npm/
 ├── sam/
 └── snowflake/
 Dockerfile (runtime stage)
+  uv sync docker/tools/azure → /opt/azure-cli on the image's python3
+    drop tests/ and the mgmt SDKs' aio/ (Microsoft's own packages drop aio too)
+    no bytecode compiled at build time
 tests/docker/validate-image.mjs
+  azure: start emulator → group create → storage account → container → blob upload → blob list
 docs/DOCKER.md, docs/AZURE.md, README.md
+  "Azure CLI" section (mount files, LOCALSTACK_AZ_WORKDIR); drop the "No Azure CLI" limitation

Microsoft's apt package bundles its own Python 3.14 and 314 MB of precompiled bytecode. The PyPI install keeps one Python in the image, and its version is pinned in a lockfile that Dependabot updates.

Evidence

Image size (du -sxm / inside the image; docker image inspect reports a compressed size for the non-native platform):

main this PR added
arm64 1,188 MB 1,513 MB +325 MB
amd64 1,185 MB 1,512 MB +327 MB
amd64, compressed (download) 358 MB 396 MB +38 MB

docker history: the Azure CLI layer is 341 MB on arm64, compared with 679 MB for #98's apt package.

Startup cost of skipping bytecode (arm64, the Azure tool's environment). az writes the bytecode on the first use of each module, because the tool's child environment does not pass PYTHONDONTWRITEBYTECODE:

apt package (#98) this PR
first az storage account create --help 210 ms 530 ms
next calls 229 ms 196 ms

Tests:

  • yarn test: 912 passed, 2 skipped, including the forwarder tests from feat(docker): bundle the Azure CLI so the Azure tool works in the image #98 and dependency-pins.test.ts.
  • Smoke test in the built image: az version reports azure-cli 2.93.0, and az storage blob upload --help runs.
  • Not run locally: the azure scenario in tests/docker/validate-image.mjs (it needs LOCALSTACK_AUTH_TOKEN). The Docker workflow runs it on this PR.

Merge Danger

Door: two-way

Blast Radius: Docker image

  • Image size: +325 MB unpacked on both platforms, +38 MB to download on amd64. AGENTS.md requires a maintainer's approval for growth above about 50 MB. Approval: pending.
  • Azure CLI version: 2.93.0, not 2.94.0: the uv project's one-week cooldown excludes 2.94.0, released on 2026-11-30. Dependabot will propose it.
  • First call per command: about 0.3 s slower, once per container. The container's writable layer then holds that command's bytecode.
  • Forwarder scope: it runs only inside a container with a non-local LOCALSTACK_HOSTNAME, and binds only 127.0.0.1:<LOCALSTACK_PORT>, where nothing listened before. npx and from-source runs are unaffected. If the port is taken (--network host), nothing is forwarded and nothing crashes.
  • Integration test time: the Docker workflow now also starts the Azure emulator.

🤖 Generated with Claude Code

Bart and others added 4 commits October 30, 2026 10:11
Replace tflocal, cdklocal, and samlocal with `lstk terraform|cdk|sam`.
The deployer always passes AWS_ENDPOINT_URL so lstk targets the
configured LocalStack instead of its own config.toml container, and
leaves the S3 endpoint to lstk, which forces path-style S3 for CDK.

The Docker image installs lstk 1.4.2 and aws-cdk 2.1145.0, drops the
*local wrappers and the aws-cdk path-style patch, and no longer needs
the s3.host.docker.internal alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge (#98)

Install azure-cli from Microsoft's apt repo. Inside the container,
*.localhost.localstack.cloud names resolve to the container itself, and
--add-host cannot cover the emulator's per-account storage hosts, so the
server forwards 127.0.0.1:<LOCALSTACK_PORT> to LOCALSTACK_HOSTNAME when
it runs in a container with LocalStack elsewhere.

Document the Azure CLI in the image and add an Azure scenario to the
Docker validation harness (group, storage account, blob upload).

Co-authored-by: Bart <bart@Barts-MacBook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Brings #98 (Azure CLI in the image) onto current main. Every file matches
main except #98's own changes, so this branch no longer carries #97's
pre-squash commit. The Dockerfile now installs the Azure CLI in its own
layer on main's per-tool structure; apt reads Microsoft's armored key
directly, so the image needs no gnupg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…size

Microsoft's apt package bundles its own Python 3.14 and precompiled
bytecode: 679 MB installed. The Azure CLI from PyPI on the image's
python3, without bytecode and without the SDKs' async clients, is 341 MB
on arm64. `az` writes its bytecode on first use of each module (the tool's
child environment does not pass PYTHONDONTWRITEBYTECODE), so only the
first call per command is slower, by about 0.3-0.4 s.

The version now lives in docker/tools/azure/uv.lock, which Dependabot
updates like the SAM and Snowflake projects, and the image keeps a single
Python.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bartsdev bartsdev changed the title Update docker image feat(docker): bundle the Azure CLI so the Azure tool works in the image Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant