From 47fcd4215416be2034a66c6aab709c8258e3ad42 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 09:43:50 -0400 Subject: [PATCH 1/6] fix hook system, git safe dir, rebase docs .lando.yml on lando 4 service --- .lando.yml | 29 +++++++++++++++-------------- builders/lando-v4.js | 16 +++++++++++++--- package-lock.json | 2 +- packages/git/git.js | 5 ++--- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.lando.yml b/.lando.yml index 1cbc060eb..07ed03a37 100644 --- a/.lando.yml +++ b/.lando.yml @@ -1,23 +1,24 @@ name: core.docs +proxy: + cli: + - core.docs.lndo.site:5173 services: cli: - api: 3 - type: lando - services: - image: node:16 - command: sleep infinity - working_dir: /app - ports: - - 8080:8080 - build: - - npm install + api: 4 + image: node:18 + command: sleep infinity + ports: + - 5173:5173/http scanner: false - ssl: false - sslExpose: false + user: node + build: + app: | + npm install tooling: node: service: cli - vuepress: - service: cli npm: service: cli + vitepress: + service: cli + cmd: npx vitepress diff --git a/builders/lando-v4.js b/builders/lando-v4.js index c76175eb2..12c9f0515 100644 --- a/builders/lando-v4.js +++ b/builders/lando-v4.js @@ -159,14 +159,24 @@ module.exports = { } #setupHooks() { - for (const hook of Object.keys(this._data.groups).filter(group => parseInt(group.weight) <= 100)) { + // filter out early stage hooks + const groups = this?._data?.groups ?? {}; + const hooks = Object.keys(this._data.groups) + .filter(group => parseInt(groups?.[group]?.weight ?? 1000) > 100) + .map(group => ([group, groups?.[group]?.user ?? 'root'])); + + // add hooks for each post boot image build group + for (const [hook, user] of hooks) { this.addSteps({group: hook, instructions: ` + USER root RUN mkdir -p /etc/lando/build/image/${hook}.d + USER ${user} RUN /etc/lando/run-hooks.sh image ${hook} `}); } } + #setupStorage() { // add top level volumes this.tlvolumes = Object.fromEntries(this.storage @@ -366,8 +376,8 @@ module.exports = { // image stage should add directly to the build context if (stage === 'image') { this.addContext( - `${file}:/etc/lando/build/image/${hook}.d/${priority}-${path.basename(file)}`, - `${hook}-1000-before`, + `${file}:/etc/lando/build/image/${hook}.d/${path.basename(file)}`, + `${hook}-1-before`, ); // app context should mount into the app diff --git a/package-lock.json b/package-lock.json index f0eb27279..6d5318f8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@lando/core", - "version": "3.21.2", + "version": "3.22.0-beta.4", "license": "GPL-3.0", "dependencies": { "@npmcli/arborist": "^6.2.9", diff --git a/packages/git/git.js b/packages/git/git.js index c8931cac0..4310dfbbf 100644 --- a/packages/git/git.js +++ b/packages/git/git.js @@ -5,9 +5,8 @@ const path = require('path'); module.exports = async service => { service.addHookFile(path.join(__dirname, 'install-git.sh'), {hook: 'boot'}); service.addHookFile(` - # temp stuff for demo purposes if command -v git > /dev/null 2>&1; then - git config --global --add safe.directory ${service.appMount} + git config --system --add safe.directory ${service.appMount} fi - `, {stage: 'app', hook: 'internal-root', id: 'git-safe'}); + `, {hook: 'tooling', priority: 0}); }; From fb273f14771e3dbb41a5c41072decbbd79429332 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 10:25:21 -0400 Subject: [PATCH 2/6] fix hook system, git safe dir, rebase docs .lando.yml on lando 4 service part 2 --- .github/workflows/pr-docs-tests.yml | 48 +++++++++++++++++++++++++++++ CHANGELOG.md | 4 +++ lib/shell.js | 2 +- plugins/proxy/app.js | 5 ++- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index 18d7c67fe..0ca52e9d7 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -32,3 +32,51 @@ jobs: run: npm run lint - name: Test build run: npm run docs:build + + lando-docs-tests: + runs-on: ${{ matrix.os }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEBUG: "@lando/*" + strategy: + matrix: + lando-version: + # - 3-slim + # uncomment to test against edge cli + - 3-edge-slim + # uncomment to test against dev cli + # - 3-dev-slim + os: + - ubuntu-24.04 + node-version: + - "18" + steps: + - name: Install node ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + registry-url: https://registry.npmjs.org + cache: npm + - name: Install dependencies + run: npm clean-install --prefer-offline --frozen-lockfile + # bundle deps is needed so local plugin installation succeeds + - name: Bundle Deps + uses: lando/prepare-release-action@v3 + with: + lando-plugin: true + version: dev + sync: false + # note that we need a custom auto-setup command because dogfooding core can impact the + # subsequent lando setup + - name: Setup lando ${{ matrix.lando-version }} + uses: lando/setup-lando@v3 + with: + auto-setup: lando plugin-add @lando/core@file:${{ github.workspace }} && lando setup + lando-version: ${{ matrix.lando-version }} + telemetry: false + config: | + setup.skipCommonPlugins=true + - name: Lando tests + run: + lando start + lando vitepress build diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bff8c9bd..d3e0547fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed bug preventing non-boot image build hooks from running +* Fixed bug causing hook files to be `COPY`ed to early in Imagefile +* Fixed bug causing `appMount` to be not correctly added as a `git` `safe.directory` + ## v3.22.0-beta.4 - [August 30, 2024](https://github.com/lando/core/releases/tag/v3.22.0-beta.4) ## Bug Fixes diff --git a/lib/shell.js b/lib/shell.js index 31ab3e64f..49a8638a7 100644 --- a/lib/shell.js +++ b/lib/shell.js @@ -156,7 +156,7 @@ module.exports = class Shell { // Return _.remove(this.running, proc => proc.id === id); - return (code !== 0) ? Promise.reject(new Error(stderr)) : Promise.resolve(stdout); + return (code !== 0) ? Promise.reject(new Error(stderr ?? stdout)) : Promise.resolve(stdout); }); }; diff --git a/plugins/proxy/app.js b/plugins/proxy/app.js index b21a53a2c..38aeeaf43 100644 --- a/plugins/proxy/app.js +++ b/plugins/proxy/app.js @@ -202,7 +202,10 @@ module.exports = (app, lando) => { }) // Warn the user if this fails - .catch(error => app.addWarning(require('./messages/cannot-start-proxy-warning')(error.message), error)); + .catch(error => { + if (!error.message || error.message === '') error.message = 'UNKNOWN ERROR'; + app.addWarning(require('./messages/cannot-start-proxy-warning')(error.message), error); + }); }); // Add proxy URLS to our app info From 8c0da280aa35b34d2817f5fba3fdee890a774653 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 10:28:11 -0400 Subject: [PATCH 3/6] fix hook system, git safe dir, rebase docs .lando.yml on lando 4 service part 3 --- .github/workflows/pr-docs-tests.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index 0ca52e9d7..5f2fc3dd1 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -16,7 +16,6 @@ jobs: node-version: - "18" steps: - # Install deps and cache - name: Checkout code uses: actions/checkout@v4 - name: Install node ${{ matrix.node-version }} @@ -51,15 +50,15 @@ jobs: node-version: - "18" steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Install node ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - registry-url: https://registry.npmjs.org cache: npm - name: Install dependencies run: npm clean-install --prefer-offline --frozen-lockfile - # bundle deps is needed so local plugin installation succeeds - name: Bundle Deps uses: lando/prepare-release-action@v3 with: From 8a986bd6f2f366040c2b4fc5555c48e2c1f7890a Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 10:30:52 -0400 Subject: [PATCH 4/6] fix hook system, git safe dir, rebase docs .lando.yml on lando 4 service part 4 --- .github/workflows/pr-docs-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index 5f2fc3dd1..d27588c55 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -78,4 +78,4 @@ jobs: - name: Lando tests run: lando start - lando vitepress build + lando vitepress build docs From 26dd1e34c6ec6b9fda15edf32dd003179b4e7f5d Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 10:33:17 -0400 Subject: [PATCH 5/6] fix hook system, git safe dir, rebase docs .lando.yml on lando 4 service part 5 --- .github/workflows/pr-docs-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-docs-tests.yml b/.github/workflows/pr-docs-tests.yml index d27588c55..2f04a1da5 100644 --- a/.github/workflows/pr-docs-tests.yml +++ b/.github/workflows/pr-docs-tests.yml @@ -76,6 +76,6 @@ jobs: config: | setup.skipCommonPlugins=true - name: Lando tests - run: + run: | lando start lando vitepress build docs From a48a2c7106b0608e1bd1b81c2aae388312b868bc Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Wed, 4 Sep 2024 11:49:21 -0400 Subject: [PATCH 6/6] update docker components and improve autosetup things --- CHANGELOG.md | 11 +++++++++++ app.js | 3 +++ config.yml | 6 +++--- hooks/app-reset-orchestrator.js | 22 ++++++++++++++++++++++ hooks/lando-setup-build-engine-darwin.js | 6 +++--- hooks/lando-setup-build-engine-win32.js | 5 ++++- hooks/lando-setup-install-ca-win32.js | 1 + hooks/lando-setup-orchestrator.js | 4 ++-- index.js | 3 ++- lib/app.js | 1 + lib/daemon.js | 2 +- utils/get-compose-x.js | 2 +- utils/get-config-defaults.js | 8 ++++---- 13 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 hooks/app-reset-orchestrator.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e0547fd..e40235a9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +### New Features + +* Updated default Docker Compose version to `2.29.2` +* Updated default Docker Desktop version to `4.34.0` +* Updated default Docker Engine version to `27.2.0` +* Updated tested Docker Desktop range to `<=4.34` +* Updated tested Docker Compose range to `<=2.29.2` + +### Bug Fixes + +* Fixed bug causing autosetup to still `U Need Setup` after installing new orchestrator on `lando start`y events * Fixed bug preventing non-boot image build hooks from running * Fixed bug causing hook files to be `COPY`ed to early in Imagefile * Fixed bug causing `appMount` to be not correctly added as a `git` `safe.directory` diff --git a/app.js b/app.js index 85fcd8a76..3bf774f08 100644 --- a/app.js +++ b/app.js @@ -133,6 +133,9 @@ module.exports = async (app, lando) => { // v4 parts of the app are ready app.events.on('ready', 6, async () => await require('./hooks/app-v4-ready')(app, lando)); + // this is a gross hack we need to do to reset the engine because the lando 3 runtime has no idea + app.events.on('ready-engine', 1, async () => await require('./hooks/app-reset-orchestrator')(app, lando)); + // Discover portforward true info app.events.on('ready-engine', async () => await require('./hooks/app-set-portforwards')(app, lando)); diff --git a/config.yml b/config.yml index 8a78c1f5e..6ec0e9a60 100644 --- a/config.yml +++ b/config.yml @@ -8,21 +8,21 @@ dockerSupportedVersions: compose: satisfies: "1.x.x || 2.x.x" recommendUpdate: "<=2.24.6" - tested: "<=2.27.1" + tested: "<=2.29.2" link: linux: https://docs.docker.com/compose/install/#install-compose-on-linux-systems darwin: https://docs.docker.com/desktop/install/mac-install/ win32: https://docs.docker.com/desktop/install/windows-install/ desktop: satisfies: ">=4.0.0 <5" - tested: "<=4.32.0" + tested: "<=4.34.0" recommendUpdate: "<=4.28.0" link: darwin: https://docs.docker.com/desktop/install/mac-install/ win32: https://docs.docker.com/desktop/install/windows-install/ engine: satisfies: ">=18 <28" - tested: "<=27.0.3" + tested: "<=27.2.0" link: linux: https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script diff --git a/hooks/app-reset-orchestrator.js b/hooks/app-reset-orchestrator.js new file mode 100644 index 000000000..3a892e6c0 --- /dev/null +++ b/hooks/app-reset-orchestrator.js @@ -0,0 +1,22 @@ +'use strict'; + +module.exports = async (app, lando) => { + // if we dont have an orchestrator bin yet then discover it + if (!!!lando.config.orchestratorBin) lando.config.orchestratorBin = require('../utils/get-compose-x')(lando.config); + + // because the entire lando 3 runtime was made in a bygone era when we never dreamed of doing stuff like this + // we need this workaround + if (lando._bootstrapLevel >= 3 && !app.engine.composeInstalled) { + app.engine = require('../utils/setup-engine')( + lando.config, + lando.cache, + lando.events, + app.log, + app.shell, + lando.config.instance, + ); + } + + // log our sitch + app.log.debug('using docker-compose %s', lando.config.orchestratorBin); +}; diff --git a/hooks/lando-setup-build-engine-darwin.js b/hooks/lando-setup-build-engine-darwin.js index eac24e74c..a117df49c 100644 --- a/hooks/lando-setup-build-engine-darwin.js +++ b/hooks/lando-setup-build-engine-darwin.js @@ -3,10 +3,10 @@ const os = require('os'); const path = require('path'); const semver = require('semver'); - const {color} = require('listr2'); - const buildIds = { + '4.34.0': '165256', + '4.33.0': '160616', '4.32.0': '157355', '4.31.0': '153195', '4.30.0': '149282', @@ -44,7 +44,7 @@ const getVersion = version => { /* * Helper to get docker compose v2 download url */ -const getEngineDownloadUrl = (id = '126437') => { +const getEngineDownloadUrl = (id = '165256') => { const arch = process.arch === 'arm64' ? 'arm64' : 'amd64'; return `https://desktop.docker.com/mac/main/${arch}/${id}/Docker.dmg`; }; diff --git a/hooks/lando-setup-build-engine-win32.js b/hooks/lando-setup-build-engine-win32.js index f771e028e..32ac11e1c 100644 --- a/hooks/lando-setup-build-engine-win32.js +++ b/hooks/lando-setup-build-engine-win32.js @@ -7,6 +7,9 @@ const {color} = require('listr2'); const {nanoid} = require('nanoid'); const buildIds = { + '4.34.0': '165256', + '4.33.1': '161083', + '4.33.0': '160616', '4.32.0': '157355', '4.31.1': '153621', '4.31.0': '153195', @@ -43,7 +46,7 @@ const getVersion = version => { /* * Helper to get docker compose v2 download url */ -const getEngineDownloadUrl = (id = '126437') => { +const getEngineDownloadUrl = (id = '165256') => { const arch = process.arch === 'arm64' ? 'arm64' : 'amd64'; return `https://desktop.docker.com/win/main/${arch}/${id}/Docker%20Desktop%20Installer.exe`; }; diff --git a/hooks/lando-setup-install-ca-win32.js b/hooks/lando-setup-install-ca-win32.js index 89b98fe6d..6d8ee3113 100644 --- a/hooks/lando-setup-install-ca-win32.js +++ b/hooks/lando-setup-install-ca-win32.js @@ -49,6 +49,7 @@ module.exports = async (lando, options) => { // finish up task.title = 'Installed Lando Development Certificate Authority (CA)'; + return result; } catch (error) { throw error; diff --git a/hooks/lando-setup-orchestrator.js b/hooks/lando-setup-orchestrator.js index 080c28fb9..d4ce69ef9 100644 --- a/hooks/lando-setup-orchestrator.js +++ b/hooks/lando-setup-orchestrator.js @@ -6,7 +6,7 @@ const path = require('path'); /* * Helper to get docker compose v2 download url */ -const getComposeDownloadUrl = (version = '2.27.1') => { +const getComposeDownloadUrl = (version = '2.29.2') => { const mv = version.split('.')[0] > 1 ? '2' : '1'; const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64'; const toggle = `${process.platform}-${mv}`; @@ -30,7 +30,7 @@ const getComposeDownloadUrl = (version = '2.27.1') => { /* * Helper to get docker compose v2 download destination */ -const getComposeDownloadDest = (base, version = '2.27.1') => { +const getComposeDownloadDest = (base, version = '2.29.2') => { switch (process.platform) { case 'linux': case 'darwin': diff --git a/index.js b/index.js index 4a80ae19d..bec06c907 100644 --- a/index.js +++ b/index.js @@ -74,8 +74,9 @@ module.exports = async lando => { // flush update cache if it needs to be lando.events.on('ready', async () => await require('./hooks/lando-flush-updates-cache')(lando)); - // this is a gross hack we need to do to reset the engine because the lando 3 runtime had no idea + // this is a gross hack we need to do to reset the engine because the lando 3 runtime has no idea lando.events.on('almost-ready', 1, async () => await require('./hooks/lando-reset-orchestrator')(lando)); + lando.events.on('post-setup', 1, async () => await require('./hooks/lando-reset-orchestrator')(lando)); // run engine compat checks lando.events.on('almost-ready', 2, async () => await require('./hooks/lando-get-compat')(lando)); diff --git a/lib/app.js b/lib/app.js index f07a24636..5dd2f53cc 100644 --- a/lib/app.js +++ b/lib/app.js @@ -112,6 +112,7 @@ module.exports = class App { this.shell, lando.config.instance, ); + this.metrics = require('../utils/setup-metrics')(this.log, lando.config); this.Promise = lando.Promise; this.events = new AsyncEvents(this.log); diff --git a/lib/daemon.js b/lib/daemon.js index 856c6a77f..96c651a64 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -57,7 +57,7 @@ module.exports = class LandoDaemon { log = new Log(), context = 'node', compose = require('../utils/get-compose-x')(), - orchestratorVersion = '2.27.1', + orchestratorVersion = '2.29.2', userConfRoot = path.join(os.homedir(), '.lando'), ) { this.cache = cache; diff --git a/utils/get-compose-x.js b/utils/get-compose-x.js index 790771b94..0e4fee376 100644 --- a/utils/get-compose-x.js +++ b/utils/get-compose-x.js @@ -27,7 +27,7 @@ const getDockerBin = (bin, base, pathFallback = true) => { } }; -module.exports = ({orchestratorVersion = '2.27.1', userConfRoot = os.tmpdir()} = {}) => { +module.exports = ({orchestratorVersion = '2.29.2', userConfRoot = os.tmpdir()} = {}) => { const orchestratorBin = `docker-compose-v${orchestratorVersion}`; switch (process.platform) { case 'darwin': diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index 82bf5e85a..45e446db9 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -8,18 +8,18 @@ const os = require('os'); const getBuildEngineVersion = () => { switch (process.platform) { case 'darwin': - return '4.32.0'; + return '4.34.0'; case 'linux': - return '27.0.3'; + return '27.2.0'; case 'win32': - return '4.32.0'; + return '4.34.0'; } }; // Default config const defaultConfig = options => ({ orchestratorSeparator: '_', - orchestratorVersion: '2.27.1', + orchestratorVersion: '2.29.2', configSources: [], disablePlugins: [], dockerBin: require('../utils/get-docker-x')(),