Add build_secrets support for local Docker builds#1021
Add build_secrets support for local Docker builds#1021alexellis merged 2 commits intoopenfaas:masterfrom
Conversation
Previously, build_secrets defined in stack.yml were only used when building with the remote builder. For local docker build and docker buildx build commands, the secrets were silently ignored. This change ports the build secrets support from the pro plugin so that local builds pass --secret id=<key>,src=<path> flags to Docker. DOCKER_BUILDKIT=1 is also set automatically when build secrets are present, since BuildKit is required for the --secret flag. Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
For parity with local builds, read file contents from build_secrets paths in stack.yaml before sealing and sending to the remote builder. Literal secret values are no longer supported. Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
AI Pull Request OverviewSummary
Approval rating (1-10)8/10 - Solid implementation with good test coverage, but breaking change for remote builder may impact existing users without file-based secrets. Summary per fileSummary per file
Overall AssessmentThe changes successfully implement Detailed ReviewDetailed Reviewbuilder/build.go
builder/build_test.go
builder/publish.go
builder/remote_builder.go
builder/remote_builder_test.go
General Concerns
Risks and Recommendations
Overall, the implementation is technically sound and well-tested. The breaking change is justified for consistency but requires careful communication to users. AI agent details. |
Description
Add support for
build_secretsin local Docker builds (faas-cli buildandfaas-cli publish). Previously,build_secretsdefined instack.ymlwere only used by the remote builder and local builds silently ignored them.As a breaking change, the remote builder now also reads file contents from
build_secretspaths before sealing and sending to the builder API. Literal secret values instack.yamlare no longer supported. This ensures consistent behaviour for both local and remote builds —build_secretsvalues are always file paths.Motivation and Context
Support for
build_secretsin local builds was previously only available in the pro plugin. This functionality has now been moved to faas-cli and will be dropped from the pro plugin. The remote builder handling was also updated to get parity between remote and local builds, wherebuild_secretsvalues are always treated as file paths.How Has This Been Tested?
RUN --mount=type=secret,id=api_keyfor:faas-cli buildandfaas-cli publishfaas-cli publish --remote-builderTypes of changes
Checklist:
git commit -s