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/docs/config.md b/docs/config.md index 1206396..d131852 100644 --- a/docs/config.md +++ b/docs/config.md @@ -103,7 +103,7 @@ The services we currently support with links to their associated Lagoon docs is Note that we are testing against the "Drupal" variants of the above but it's _possible_ the base services work as well. -*Please note: if using [uselagoon/solr-8-drupal](https://github.com/uselagoon/lagoon-images/blob/main/images/solr-drupal/8.Dockerfile) you will need to add the following command to your `Solr` service in your `.lando.yml` file. Alternate Solr images are supported and may require different commands, this is just one example. +*Please note: if using [uselagoon/solr-9-drupal](https://github.com/uselagoon/lagoon-images/blob/main/images/solr-drupal/9.Dockerfile) you will need to add the following command to your `Solr` service in your `.lando.yml` file. Alternate Solr images are supported and may require different commands, this is just one example. ```yaml recipe: lagoon diff --git a/examples/all-services/docker-compose.yml b/examples/all-services/docker-compose.yml index 6945a96..30edf19 100644 --- a/examples/all-services/docker-compose.yml +++ b/examples/all-services/docker-compose.yml @@ -25,7 +25,7 @@ services: lagoon.type: node lando.type: node ports: - - "3000" + - "3001:3000" user: root environment: << : *default-environment # loads the defined environment variables from the top @@ -38,7 +38,7 @@ services: lagoon.type: python lando.type: python ports: - - "8800" + - "8801:8800" environment: << : *default-environment # loads the defined environment variables from the top networks: @@ -50,7 +50,7 @@ services: lagoon.type: ruby lando.type: ruby ports: - - "3000" + - "3002:3000" environment: << : *default-environment # loads the defined environment variables from the top networks: @@ -74,7 +74,7 @@ services: lagoon.type: basic lando.type: basic ports: - - "3000" + - "3003:3000" user: root environment: << : *default-environment # loads the defined environment variables from the top diff --git a/examples/drupal9-base/README.md b/examples/drupal9-base/README.md index 3049337..91c282f 100644 --- a/examples/drupal9-base/README.md +++ b/examples/drupal9-base/README.md @@ -41,6 +41,16 @@ 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 +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 lando ssh -c "env | grep LAGOON=" | grep cli-drupal diff --git a/examples/proxy-tests/docker-compose.yml b/examples/proxy-tests/docker-compose.yml index f820d51..32f49e5 100644 --- a/examples/proxy-tests/docker-compose.yml +++ b/examples/proxy-tests/docker-compose.yml @@ -25,7 +25,7 @@ services: lagoon.type: node lando.type: node ports: - - "3000" + - "3011:3000" user: root environment: << : *default-environment # loads the defined environment variables from the top @@ -38,7 +38,7 @@ services: lagoon.type: python lando.type: python ports: - - "8800" + - "8811:8800" environment: << : *default-environment # loads the defined environment variables from the top networks: @@ -50,7 +50,7 @@ services: lagoon.type: ruby lando.type: ruby ports: - - "3000" + - "3012:3000" environment: << : *default-environment # loads the defined environment variables from the top networks: 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(); diff --git a/lib/proxy.js b/lib/proxy.js index 02cd86d..443698c 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -26,7 +26,8 @@ const getBasicContainers = services => { const basicContainers = _(services).filter(service => service.type === 'lagoon-basic').map('name').value(); let basicPort = ''; if (!_.isEmpty(basicContainers)) { - basicPort = services[_.first(basicContainers)].lagoon.ports[0]; + const port = services[_.first(basicContainers)].lagoon.ports[0]; + basicPort = port.includes(':') ? port.split(':')[1] : port; } return [basicContainers, basicPort]; }; diff --git a/package-lock.json b/package-lock.json index 1e737a4..f387390 100644 --- a/package-lock.json +++ b/package-lock.json @@ -176,6 +176,7 @@ "integrity": "sha512-mVnkDZjpbiqdXRz0NrQlx6+QsnKYENuruYyjTJNcG3qAe015tvGAHcvvzRT78ZxETS7WjruWSlXBcL5llycNsQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@algolia/client-common": "5.16.0", "@algolia/requester-browser-xhr": "5.16.0", @@ -318,6 +319,7 @@ "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.26.0", @@ -1348,13 +1350,13 @@ } }, "node_modules/@lando/argv": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@lando/argv/-/argv-1.1.2.tgz", - "integrity": "sha512-b3d4zF1QBrFgUCFxEb48b0hse98wRhfnnydFsKXTcQc4aogfCBZc9wbgktLrs6TUtLKvU57YtlfNU4ack1ll7w==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@lando/argv/-/argv-1.2.0.tgz", + "integrity": "sha512-Usr0FuXfzDezQG7ZSuaaMNoF9v/YsavgnclQqTBzV48oku/vi9fiKttlaSoXOQ1UPrC1KPC/ean1ZrDnZqcosw==", "dev": true, - "license": "GPL-3.0", + "license": "MIT", "engines": { - "node": ">=14.0.0" + "node": ">=20.0.0" } }, "node_modules/@lando/chai": { @@ -2922,6 +2924,7 @@ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2986,6 +2989,7 @@ "integrity": "sha512-0zWz0LGfB0MLrhcnyGDpvVWPSsZnECNU6V/GPtNkHHSgaUj/7i+j36bZm6HClCvo8GvuxbN+ccbFREWUouHlfg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@algolia/client-abtesting": "5.16.0", "@algolia/client-analytics": "5.16.0", @@ -3243,6 +3247,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001669", "electron-to-chromium": "^1.5.41", @@ -4117,6 +4122,7 @@ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.3", @@ -4653,6 +4659,7 @@ "integrity": "sha512-9FhUxK1hVju2+AiQIDJ5Dd//9R2n2RAfJ0qfhF4IHGHgcoEUTMpbTeG/zbEuwaiYXfuAH6XE0/aCyxDdRM+W5w==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "tabbable": "^6.2.0" } @@ -8321,6 +8328,7 @@ "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", @@ -8381,6 +8389,7 @@ "integrity": "sha512-q4Q/G2zjvynvizdB3/bupdYkCJe2umSAMv9Ju4d92E6/NXJ59z70xB0q5p/4lpRyAwflDsbwy1mLV9Q5+nlB+g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@docsearch/css": "^3.6.2", "@docsearch/js": "^3.6.2", @@ -8434,6 +8443,7 @@ "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.13", "@vue/compiler-sfc": "3.5.13",