Add builder.additional_contexts configuration to natively pass additional build contexts - #1929
Open
crydafan wants to merge 1 commit into
Open
Add builder.additional_contexts configuration to natively pass additional build contexts#1929crydafan wants to merge 1 commit into
builder.additional_contexts configuration to natively pass additional build contexts#1929crydafan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
While migrating from Docker Compose to Kamal in production, one of our Dockerfiles copies scripts from a context inside the app context:
COPY --from=scripts . .Docker Compose has a native option to declare these extra build contexts via
additional_contexts:Kamal had no equivalent, so the build broke during migration — there was no way to pass
--build-contextto Buildx from the deploy config.Fix
Kamal now supports declaring additional build contexts under
builder.additional_contextsindeploy.yml:Each entry is passed through to Buildx as
--build-context <name>=<value>and can be referenced in the Dockerfile viaCOPY --from=<name>.Implementation
lib/kamal/configuration/builder.rb): added anadditional_contextsreader that returns the configured hash (or{}).lib/kamal/configuration/validator.rb):additional_contextsis treated as a free-form Hash (likeargs/options) since its keys are user-defined; the option is also documented indocs/builder.yml, which doubles as the schema example.lib/kamal/commands/builder/base.rb): added abuild_additional_contextsmethod that formats each key/value pair using the existingargumentizehelper and appends the result tobuild_options. All drivers (local, remote, hybrid, cloud) inherit fromBase, so they all pick this up.--build-contextflags in bothbuild_optionsand the fulldocker buildx buildcommand.