From 64b67f29a1dc036aa95827ed4d62c781e5d81bb9 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Mon, 9 Mar 2026 20:16:03 -0500 Subject: [PATCH 1/3] fix: strip additional_contexts and resolve relative build contexts - 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 --- builders/_lagoon.js | 7 +++++-- lib/config.js | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/builders/_lagoon.js b/builders/_lagoon.js index 45a75e7..c7e5860 100644 --- a/builders/_lagoon.js +++ b/builders/_lagoon.js @@ -20,8 +20,11 @@ module.exports = { const hostnames = _.get(options, '_app.lagoon.containers', []); // Normalize the dockerfile situation - // We need to do this again since this isnt technically an override - if (_.has(lagoon, 'build.context')) lagoon.build.context = path.join(options.root); + // Resolve build context relative to the project root so non-root contexts + // (eg context: frontend) work correctly instead of always forcing root + if (_.has(lagoon, 'build.context')) { + lagoon.build.context = path.resolve(options.root, lagoon.build.context); + } // Handle portfoward in the usual way if (options.portforward) { diff --git a/lib/config.js b/lib/config.js index 1da63f3..6361af2 100644 --- a/lib/config.js +++ b/lib/config.js @@ -44,11 +44,20 @@ exports.loadConfigFiles = baseDir => { */ exports.parseServices = (services, recipeConfig) => _(services) // Remove unneeded things from the docker config and determine the type of the service - .map((config, name) => _.merge({}, { - name, - type: getLabel(config.labels), - compose: _.omit(config, ['volumes', 'volumes_from', 'networks', 'user']), - config: recipeConfig, - })) + .map((config, name) => { + // Strip additional_contexts from build config since Lando splits services + // into separate compose files and service: refs cant resolve across them + if (_.has(config, 'build.additional_contexts')) { + config = _.cloneDeep(config); + delete config.build.additional_contexts; + } + + return _.merge({}, { + name, + type: getLabel(config.labels), + compose: _.omit(config, ['volumes', 'volumes_from', 'networks', 'user']), + config: recipeConfig, + }); + }) // Return .value(); From 4d7ad1f459c860f9c62f18e9751b7432aac8ab4c Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Mon, 9 Mar 2026 20:40:59 -0500 Subject: [PATCH 2/3] test: validate CLI_IMAGE cross-service builds and additional_contexts 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 --- examples/drupal9-base/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/drupal9-base/README.md b/examples/drupal9-base/README.md index 3049337..5d19b72 100644 --- a/examples/drupal9-base/README.md +++ b/examples/drupal9-base/README.md @@ -41,6 +41,15 @@ docker ps --filter label=com.docker.compose.project | grep Up | grep drupalbase_ docker ps --filter label=com.docker.compose.project | grep Up | grep drupalbase_php_1 docker ps --filter label=com.docker.compose.project | grep Up | grep drupalbase_cli_1 +# Should have built nginx and php from the cli image via CLI_IMAGE build arg +cd drupal +lando ssh -s cli -c "test -f /app/web/index.php" +lando ssh -s nginx -c "test -f /app/web/index.php" +lando ssh -s php -c "test -f /app/web/index.php" + +# Should not have additional_contexts in the generated compose files +cat ~/.lando/compose/drupalbase-* 2>/dev/null | grep -c "additional_contexts" | grep 0 + # Should ssh against the cli container by default cd drupal lando ssh -c "env | grep LAGOON=" | grep cli-drupal From 13c609d4e29b502327fdac47996411736d78f1c4 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Mon, 9 Mar 2026 23:00:42 -0500 Subject: [PATCH 3/3] fix: correct additional_contexts assertion in drupal9-base leia test 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. --- examples/drupal9-base/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/drupal9-base/README.md b/examples/drupal9-base/README.md index 5d19b72..91c282f 100644 --- a/examples/drupal9-base/README.md +++ b/examples/drupal9-base/README.md @@ -48,7 +48,8 @@ lando ssh -s nginx -c "test -f /app/web/index.php" lando ssh -s php -c "test -f /app/web/index.php" # Should not have additional_contexts in the generated compose files -cat ~/.lando/compose/drupalbase-* 2>/dev/null | grep -c "additional_contexts" | grep 0 +cd drupal +cat ~/.lando/compose/drupalbase-* 2>/dev/null | grep "additional_contexts" && exit 1 || true # Should ssh against the cli container by default cd drupal