fix: strip additional_contexts and resolve relative build contexts#107
Open
AaronFeledy wants to merge 3 commits intomainfrom
Open
fix: strip additional_contexts and resolve relative build contexts#107AaronFeledy wants to merge 3 commits intomainfrom
AaronFeledy wants to merge 3 commits intomainfrom
Conversation
- Strip build.additional_contexts from parsed service config since Lando splits services into separate compose files and service: refs cannot resolve across them. The CLI_IMAGE build arg handles cross-service image references instead. - Use path.resolve instead of path.join for build.context so relative contexts (eg context: frontend for monorepos) resolve correctly against the project root instead of always being forced to root. Fixes #7, fixes #53
❌ Deploy Preview for lando-lagoon failed. Why did it fail? →
|
… stripping Adds assertions to drupal9-base leia test: - Verify nginx and php services have /app/web/index.php (copied from cli via CLI_IMAGE build arg, proving cross-service builds work) - Verify additional_contexts is stripped from generated compose files
grep -c exits non-zero when count is 0, causing the test to fail even though the assertion is correct. Use grep + exit 1 pattern instead.
Collaborator
|
Not sure if you want a formal review from us, but this makes sense - when users first encountered this with Lando, we told them to remove the additional_contexts, so I can't foresee it causing too many issues. Obviously, any newcomers can use the templates straight OOTB now. |
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
Two related build issues with the Lagoon plugin:
additional_contextswithservice:references fail — Upstream lagoon-examples/drupal-base addedadditional_contextsin Aug 2025 to enforce BuildKit build ordering. Lando splits services into separate compose files, so Docker can't resolveservice:cliacross files and treats it as a filesystem path (~/.lando/compose/drupalbase/service:cli), causing all leia-tests to fail.build.contextalways forced to project root —_lagoon.jsrewritesbuild.contexttopath.join(options.root)regardless of the original value, breaking monorepo setups where services use non-root contexts (e.g.context: frontend).Fix
Strip
build.additional_contextsinlib/config.jsduring service parsing. TheCLI_IMAGEbuild arg already handles cross-service image references (ARG CLI_IMAGE→FROM ${CLI_IMAGE} AS cli), makingadditional_contextsredundant for local dev.Use
path.resolveinstead ofpath.joinin_lagoon.jsso relative build contexts resolve correctly against the project root.context: .still resolves to root (no regression), butcontext: frontendnow correctly resolves to<root>/frontend.Testing
additional_contextsFixes #7
Fixes #53
Note
Medium Risk
Touches Lagoon service build configuration, which can affect how images are built and may break projects relying on current (incorrect) context rewriting or on
additional_contextsbehavior. Scope is limited to local compose/service parsing and build context normalization (no auth/data handling).Overview
Fixes Lagoon build compatibility in two places.
builders/_lagoon.jsnow resolvesbuild.contextrelative to the project root (instead of forcing root), enabling non-root build contexts in monorepos.lib/config.jsstripsbuild.additional_contextsduring service parsing to avoid Dockerservice:context references that can’t resolve when Lando splits services into separate compose files.Updates the Drupal 9 base example README with verification steps to confirm images build via the shared CLI image and that generated compose files do not contain
additional_contexts.Written by Cursor Bugbot for commit 13c609d. This will update automatically on new commits. Configure here.