feat: add docker build network option to azure.yaml#7361
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for configuring Docker build networking from azure.yaml via a new services.<name>.docker.network option, enabling scenarios (like corporate proxies) that require passing --network to docker build.
Changes:
- Added a
buildNetworkparameter to(*docker.Cli).Build()and appends--network <value>when set. - Plumbed
docker.networkfromazure.yaml(DockerProjectOptions.Network) throughContainerHelperinto the Docker build invocation. - Updated both
v1.0andalphaazure.yamlJSON schemas and added unit test coverage for the new flag.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| schemas/v1.0/azure.yaml.json | Adds docker.network property to the v1.0 schema. |
| schemas/alpha/azure.yaml.json | Adds docker.network property to the alpha schema. |
| cli/azd/pkg/tools/docker/docker.go | Extends Build() to accept buildNetwork and pass --network to the build command. |
| cli/azd/pkg/tools/docker/docker_test.go | Adds a table-driven test to verify --network is included/omitted as expected. |
| cli/azd/pkg/tools/docker/acceptance/acceptance_test.go | Updates Build call site to include the new parameter. |
| cli/azd/pkg/project/framework_service_docker.go | Adds Network to DockerProjectOptions to support azure.yaml config. |
| cli/azd/pkg/project/container_helper.go | Passes dockerOptions.Network through to docker.Build(). |
jongio
left a comment
There was a problem hiding this comment.
PR Review - #7361
feat: add docker build network option to azure.yaml by @spboyer
Summary
What: Adds docker.network field to azure.yaml that passes --network to docker build, enabling builds requiring host networking (e.g., corporate proxies).
Why: Fixes #4758 - users had no way to configure Docker's network mode, forcing a shell script shim workaround.
Assessment: Clean implementation. The --network conditional mirrors the existing --target pattern. All callers updated, both schemas updated, table-driven test covers on/off behavior. No issues found.
Findings
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Total | 0 | 0 | 0 | 0 |
Test Coverage Estimate
Test_DockerBuildNetworkcovers bothhost(flag present) and""(flag absent)- All existing Build test call sites updated for the new parameter
- No coverage gaps for changed code
What's Done Well
- Minimal, surgical change with zero scope creep
- Follows the
--targetconditional pattern exactly - Table-driven test matching file conventions
- Both v1.0 and alpha schemas updated
Allow users to specify `docker.network` in azure.yaml service config (e.g., `network: host`) which is passed as `--network` to docker build. This enables builds behind corporate proxies that need host networking. Fixes #4758 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ef60ad4 to
286748d
Compare
jongio
left a comment
There was a problem hiding this comment.
PR Review - #7361
feat: add docker build network option to azure.yaml by @spboyer
Summary
What: Adds docker.network to azure.yaml service config, passing --network to docker build for builds that need host networking (corporate proxies).
Why: Fixes #4758 - no way to configure Docker's network mode without wrapper scripts.
Assessment: Clean implementation mirroring the existing --target pattern. All callers updated, both schemas updated, solid table-driven test. One gap: the gRPC proto and mapper for DockerProjectOptions don't include Network, so extensions won't see the setting.
Findings
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic | 0 | 1 | 0 | 0 |
| Total | 0 | 1 | 0 | 0 |
Test Coverage Estimate
Test_DockerBuildNetworkcovershost(flag present) and""(flag absent)- All existing Build test call sites updated for the new parameter
- No coverage gaps for changed code
What's Done Well
- Follows the
--targetconditional pattern exactly - Table-driven test matching file conventions
- Both v1.0 and alpha schemas updated together
1 inline comment below.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
PR Review - #7361
feat: add docker build network option to azure.yaml by @spboyer
Summary
What: Adds docker.network to azure.yaml service config, passing --network to docker build. Enables builds behind corporate proxies needing host networking.
Why: Fixes #4758 - no way to configure Docker's build network mode without wrapper scripts.
Assessment: The original commit was solid - clean implementation mirroring the --target pattern. The follow-up commit (d05ae4e) addresses the proto/mapper gap from the previous review, but the .pb.go file was hand-edited instead of regenerated. The raw file descriptor is stale, so the field won't actually serialize over gRPC.
Findings
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic | 0 | 1 | 0 | 0 |
| Total | 0 | 1 | 0 | 0 |
Key Findings
- [HIGH] Logic:
models.pb.gohand-edited instead of regenerated - Network field won't serialize over gRPC
Test Coverage Estimate
Test_DockerBuildNetworkcovershostand""cases for the docker CLI layer- All existing Build call sites updated for the new parameter
- No mapper/proto serialization tests (consistent with repo pattern)
What's Done Well
- Original implementation cleanly follows the
--targetconditional pattern - Table-driven test matching repo conventions
- Both v1.0 and alpha schemas updated together
- Proto field number 10 and mapper additions in the follow-up are correct
1 inline comment below.
The previous commit hand-edited models.pb.go to add the Network field, but the raw file descriptor was not updated. Without field 10 in the descriptor, proto.Marshal() would not serialize Network over gRPC. Regenerated using 'make proto' to include the Network field properly in the wire format. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Previous comments addressed. pb.go properly regenerated with protoc - raw descriptor now includes field 10 (network). LGTM.
jongio
left a comment
There was a problem hiding this comment.
Previous approval stands. One additional note:
- mapper_registry_test.go -
TestDockerProjectOptionsMappingandTestFromProtoDockerProjectOptionsMappingdon't set or assert the newNetworkfield, so the mapper round-trip isn't covered by tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use switch statement for TestPtr to keep nil-check and dereference in the same branch. Add nolint directive for TestMCPSecurityFluentBuilder where t.Fatal guarantees non-nil. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace manual nil-check + t.Fatal with require.NotNil which makes staticcheck aware the pointer is non-nil for subsequent accesses. Convert all manual assertions to require.True/require.Len. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
weikanglim
left a comment
There was a problem hiding this comment.
LGTM. I am much in favor of this change directionally since it aligns well with the same network option in docker-compose which users are familiar with.
- Add AZD_NON_INTERACTIVE environment variable to environment-variables.md (--non-interactive flag alias and env var, PR Azure#7392) - Add azd auth token usage section to external-authentication.md (raw token output by default, --output json for structured output, PR Azure#7384) - Add Docker build network option to proxy-configuration.md (docker.network field in azure.yaml for builds behind corporate proxies, PR Azure#7361) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 1.24.0 (Unreleased) CHANGELOG section documenting: - --non-interactive flag alias and AZD_NON_INTERACTIVE env var (Azure#7392) - Hooks per provisioning layer in azure.yaml (Azure#7382) - Docker build network option in azure.yaml (Azure#7361) - Improved azd update error message for admin-managed installs (Azure#7417) - Deprecation of -e short flag in AI extensions (Azure#7313) - Add AZD_NON_INTERACTIVE to environment-variables.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Fixes #4758
Adds a
docker.networkoption to azure.yaml service config that passes--networktodocker build. This enables builds behind corporate proxies that need host networking.Changes
docker.go— AddedbuildNetworkparam toBuild(); appends--network <value>when non-emptyframework_service_docker.go— AddedNetworkfield toDockerProjectOptionscontainer_helper.go— PassesdockerOptions.Networkthrough todocker.Build()docker_test.go— Table-driven test for network optionv1.0andalphaazure.yaml schemasUsage