From 4ea4af66b1e37355e988de4f5a35df224c29da97 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Mon, 29 Apr 2024 21:40:28 -0400 Subject: [PATCH 01/14] ACTUALLY delay between docker start retries --- hooks/lando-autostart-engine.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hooks/lando-autostart-engine.js b/hooks/lando-autostart-engine.js index 339608897..e57c0b3f1 100644 --- a/hooks/lando-autostart-engine.js +++ b/hooks/lando-autostart-engine.js @@ -8,8 +8,10 @@ module.exports = async lando => { const debug = require('../utils/debug-shim')(lando.log); const tasks = [{ title: 'It seems Docker is not running, trying to start it up...', - retry: 25, - delay: 1000, + retry: { + tries: 25, + delay: 1000, + }, task: async (ctx, task) => { // prompt for password if interactive and we dont have it if (process.platform === 'linux' && lando.config.isInteractive) { From 956ba9235b5dbaf106060c5e40a5485a0e141f4e Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Wed, 1 May 2024 21:44:11 -0400 Subject: [PATCH 02/14] detect docker installed via windows/wsl interop --- utils/is-wsl-interop.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 utils/is-wsl-interop.js diff --git a/utils/is-wsl-interop.js b/utils/is-wsl-interop.js new file mode 100644 index 000000000..1d66b55aa --- /dev/null +++ b/utils/is-wsl-interop.js @@ -0,0 +1,11 @@ +'use strict'; + +const fs = require('fs'); +const os = require('os'); + +// Checks to see if Docker is installed via WSL/Windows interop. +module.exports = engineBin => { + const isWsl = os.release().toLowerCase().includes('microsoft'); + // Docker Desktop for Windows keeps the .exe in the same directory as the WSL binary. + return isWsl && fs.existsSync(`${engineBin}.exe`); +}; From 62e07b157c2287bad5a32a4aa0d1644df27a74d8 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Thu, 2 May 2024 16:02:59 -0400 Subject: [PATCH 03/14] Start Docker Desktop for Windows from WSL2 linux --- hooks/lando-autostart-engine.js | 8 +++- lib/daemon.js | 42 ++++++++++++++----- scripts/docker-desktop-start.ps1 | 69 ++++++++++++++++++++++++++++++++ utils/get-config-defaults.js | 1 + 4 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 scripts/docker-desktop-start.ps1 diff --git a/hooks/lando-autostart-engine.js b/hooks/lando-autostart-engine.js index e57c0b3f1..58959105a 100644 --- a/hooks/lando-autostart-engine.js +++ b/hooks/lando-autostart-engine.js @@ -13,8 +13,12 @@ module.exports = async lando => { delay: 1000, }, task: async (ctx, task) => { - // prompt for password if interactive and we dont have it - if (process.platform === 'linux' && lando.config.isInteractive) { + // Prompt for sudo password if interactive and not Docker Desktop WSL2 integration + if ( + process.platform === 'linux' + && lando.config.isInteractive + && !require('../utils/is-wsl-interop')(lando.engine.daemon.docker) + ) { ctx.password = await task.prompt({ type: 'password', name: 'password', diff --git a/lib/daemon.js b/lib/daemon.js index 3cd152268..ba5b3ff6d 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -19,16 +19,23 @@ const macOSBase = '/Applications/Docker.app'; /* * Get services wrapper */ -const buildDockerCmd = (cmd, scriptsDir) => { +const buildDockerCmd = (cmd, scriptsDir, dockerBin) => { + const windowsStartScript = path.join(scriptsDir, 'docker-desktop-start.ps1'); switch (process.platform) { case 'darwin': return ['open', macOSBase]; case 'linux': + if (require('../utils/is-wsl-interop')(dockerBin)) { + // Docker Desktop WSL2 integration detected + return [ + 'powershell.exe', '-ExecutionPolicy', 'Bypass', '-File', windowsStartScript, + ]; + } return [path.join(scriptsDir, `docker-engine-${cmd}.sh`)]; case 'win32': const base = process.env.ProgramW6432 || process.env.ProgramFiles; - const dockerBin = base + '\\Docker\\Docker\\Docker Desktop.exe'; - return ['cmd', '/C', `"${dockerBin}"`]; + const dockerDesktopBin = base + '\\Docker\\Docker\\Docker Desktop.exe'; + return ['cmd', '/C', `"${dockerDesktopBin}"`]; } }; @@ -86,12 +93,19 @@ module.exports = class LandoDaemon { if (this.context !== 'node' && process.platform === 'linux') return Promise.resolve(true); // special handling for linux - if (this.context === 'node' && process.platform === 'linux') { + if ( + this.context === 'node' + && process.platform === 'linux' + && !require('../utils/is-wsl-interop')(this.docker) + ) { return this.isUp().then(async isUp => { if (!isUp) { const debug = require('../utils/debug-shim')(this.log); try { - await require('../utils/run-elevated')(buildDockerCmd('start', this.scriptsDir), {debug, password}); + await require('../utils/run-elevated')( + buildDockerCmd('start', this.scriptsDir, this.docker), + {debug, password}, + ); return Promise.resolve(true); } catch (error) { this.log.debug('%j', error); @@ -105,7 +119,7 @@ module.exports = class LandoDaemon { return this.isUp().then(async isUp => { if (!isUp) { const retryOpts = retry ? {max: 25, backoff: 1000} : {max: 0}; - return shell.sh(buildDockerCmd('start', this.scriptsDir)) + return shell.sh(buildDockerCmd('start', this.scriptsDir, this.docker)) .catch(err => { throw Error('Could not automatically start the Docker Daemon. Please manually start it to continue.'); }) @@ -144,7 +158,11 @@ module.exports = class LandoDaemon { .then(() => { // Automatically return true if we are in browsery context and on linux because // this requires SUDO and because the daemon should always be running on nix - if (this.context !== 'node' && process.platform === 'linux') return Promise.resolve(true); + if ( + this.context !== 'node' + && process.platform === 'linux' + && !require('../utils/is-wsl-interop')(this.docker) + ) return Promise.resolve(true); // Automatically return if we are on Windows or Darwin because we don't // ever want to automatically turn the VM off since users might be using // D4M/W for other things. @@ -154,10 +172,14 @@ module.exports = class LandoDaemon { // // @todo: When/if we can run our own isolated docker daemon we can change // this back. - if (process.platform === 'win32' || process.platform === 'darwin') return Promise.resolve(true); + if ( + process.platform === 'win32' + || process.platform === 'darwin' + || require('../utils/is-wsl-interop')(this.docker) + ) return Promise.resolve(true); // Shut provider down if its status is running. return this.isUp(this.log, this.cache, this.docker).then(isUp => { - if (isUp) return shell.sh(buildDockerCmd('stop', this.scriptsDir), {mode: 'collect'}); + if (isUp) return shell.sh(buildDockerCmd('stop', this.scriptsDir, this.docker), {mode: 'collect'}); }) // Wrap errors. .catch(err => { @@ -191,7 +213,7 @@ module.exports = class LandoDaemon { return Promise.resolve(true); }) .catch(error => { - log.debug('engine is down with error %j', error); + log.debug('engine is down with error %s', error.message); return Promise.resolve(false); }); }; diff --git a/scripts/docker-desktop-start.ps1 b/scripts/docker-desktop-start.ps1 new file mode 100644 index 000000000..98b503919 --- /dev/null +++ b/scripts/docker-desktop-start.ps1 @@ -0,0 +1,69 @@ +$ErrorActionPreference = "Stop" + +# Lando is impatient and will keep trying to start Docker Desktop if it's not ready. +# Using a mutex to ensure only one instance of this script runs at a time. +$mutexName = "Global\DockerDesktopStartLock" +$mutex = New-Object System.Threading.Mutex($false, $mutexName) +$lockAcquired = $false + +try { + $lockAcquired = $mutex.WaitOne(0, $false) + if (-not $lockAcquired) { + Write-Output "Another instance of the script is already starting Docker Desktop." + exit 0 + } + + $AppName = "Docker Desktop" + $app = "shell:AppsFolder\$((Get-StartApps $AppName | Select-Object -First 1).AppId)" + $startMenuPath = [System.Environment]::GetFolderPath("CommonStartMenu") + $shortcutPath = Join-Path $startMenuPath "Docker Desktop.lnk" + $programFiles = [System.Environment]::GetFolderPath("ProgramFiles") + $exePath = Join-Path $programFiles "Docker\Docker\Docker Desktop.exe" + + if (Get-Process -Name "Docker Desktop" -ErrorAction SilentlyContinue) { + Write-Output "Docker Desktop is already running." + exit 0 + } + + function Start-App($path) { + Write-Debug "Attempting to start $path" + if (Test-Path $path) { + Start-Process $path + return $true + } + return $false + } + + # Try to start via the App, Start Menu shortcut, then Program Files + if (!(Start-App $app) -and !(Start-App $shortcutPath) -and !(Start-App $exePath)) { + Write-Output "Docker Desktop could not be started. Please check the installation." + exit 1 + } + + # Wait for Docker Desktop to start (Lando only waits 25 seconds before giving up) + $timeout = 25 + for ($i = $timeout; $i -gt 0; $i--) { + if (($i % 5) -eq 0) { Write-Debug "Waiting for Docker Desktop to start ($i seconds remaining)" } + Start-Sleep -Seconds 1 + + if (Get-Process -Name "Docker Desktop" -ErrorAction SilentlyContinue) { + try { + docker info -f '{{.ServerVersion}}' 2>$null | Out-Null + Write-Host "Docker Desktop is running." + break + } catch { + # Ignore error + } + } + } +} +catch { + Write-Error "An error occurred: $_" + exit 1 +} +finally { + if ($lockAcquired) { + $mutex.ReleaseMutex() + } + $mutex.Dispose() +} diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index 91c857e70..c77faf071 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -23,6 +23,7 @@ const defaultConfig = options => ({ platform: os.platform(), release: os.release(), arch: os.arch(), + isWsl: os.release().toLowerCase().includes('microsoft'), }, pluginDirs: [{path: path.join(__dirname, '..'), subdir: 'plugins', namespace: '@lando'}], plugins: [{name: '@lando/core', path: path.join(__dirname, '..'), type: 'local'}], From 48366c2930a744482ecb0ad6a9404e5eb1577527 Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Fri, 3 May 2024 22:10:21 -0400 Subject: [PATCH 04/14] Use new docker desktop startup script on windows --- lib/daemon.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/daemon.js b/lib/daemon.js index ba5b3ff6d..5076dc45a 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -28,14 +28,14 @@ const buildDockerCmd = (cmd, scriptsDir, dockerBin) => { if (require('../utils/is-wsl-interop')(dockerBin)) { // Docker Desktop WSL2 integration detected return [ - 'powershell.exe', '-ExecutionPolicy', 'Bypass', '-File', windowsStartScript, + 'powershell.exe', '-ExecutionPolicy', 'Bypass', '-File', `"${windowsStartScript}"`, ]; } return [path.join(scriptsDir, `docker-engine-${cmd}.sh`)]; case 'win32': - const base = process.env.ProgramW6432 || process.env.ProgramFiles; - const dockerDesktopBin = base + '\\Docker\\Docker\\Docker Desktop.exe'; - return ['cmd', '/C', `"${dockerDesktopBin}"`]; + return [ + 'powershell.exe', '-ExecutionPolicy', 'Bypass', '-File', `"${windowsStartScript}"`, + ]; } }; From 652f724b23d06bc23d1990fbdabf55fbd73aefef Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Sat, 4 May 2024 10:44:35 -0400 Subject: [PATCH 05/14] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593f92858..6ec2effb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## Unreleased * Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) +* Added ability to autostart Docker Desktop for Windows from within WSL instances +* Improved method for locating and starting Docker Desktop on Windows +* Fixed bug that caused Lando to be too impatient when starting Docker Desktop ## v3.21.0-beta.18 - [April 29, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.18) From 4341375b1515cbbf3e2f1f3f6a541c79ac822eae Mon Sep 17 00:00:00 2001 From: Aaron Feledy Date: Sat, 4 May 2024 14:33:12 -0400 Subject: [PATCH 06/14] disable repeating 1s retry timer --- hooks/lando-autostart-engine.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hooks/lando-autostart-engine.js b/hooks/lando-autostart-engine.js index 58959105a..cde44ce90 100644 --- a/hooks/lando-autostart-engine.js +++ b/hooks/lando-autostart-engine.js @@ -44,6 +44,11 @@ module.exports = async lando => { } }, }]; - await lando.runTasks(tasks, {listrOptions: {exitOnError: true}}); + await lando.runTasks(tasks, { + listrOptions: {exitOnError: true}, + rendererOptions: { + pausedTimer: {condition: false}, + }, + }); } }; From 72a7eac46833e49c90c7994d49651afaf3477ee5 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 08:34:23 -0400 Subject: [PATCH 07/14] Fixed unclear error when cancelling certain prompts --- CHANGELOG.md | 3 ++- utils/run-tasks.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593f92858..97c011f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## Unreleased +## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed unclear error when cancelling certain prompts * Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) ## v3.21.0-beta.18 - [April 29, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.18) diff --git a/utils/run-tasks.js b/utils/run-tasks.js index a204b4f42..c5ded9d66 100644 --- a/utils/run-tasks.js +++ b/utils/run-tasks.js @@ -42,6 +42,7 @@ module.exports = async (tasks, { exitOnError: false, fallbackRenderer, fallbackRendererOptions, + registerSignalListeners: false, renderer, rendererOptions: { log: require('debug')('task-runner'), @@ -72,6 +73,7 @@ module.exports = async (tasks, { // get results const results = await runner.run(); + // update results and then return results.skipped = tasks.filter(task => !task.enabled).length; results.ran = tasks.filter(task => task.enabled).length; From 45bcd57459162672c684581df025f3177f63896d Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 08:51:45 -0400 Subject: [PATCH 08/14] #165: change download-x to prefer ipv4 and improved error handling --- CHANGELOG.md | 2 ++ utils/download-x.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c011f94..d1e3941a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Changed `download-x` to prefer `ipv4` [#165](https://github.com/lando/core/pull/165) * Fixed unclear error when cancelling certain prompts +* Improved error handling on `download-x` [#165](https://github.com/lando/core/pull/165) * Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) ## v3.21.0-beta.18 - [April 29, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.18) diff --git a/utils/download-x.js b/utils/download-x.js index a4f0cd92e..961508661 100644 --- a/utils/download-x.js +++ b/utils/download-x.js @@ -1,13 +1,20 @@ 'use strict'; -const axios = require('axios'); const fs = require('fs'); +const http = require('http'); +const https = require('https'); const os = require('os'); const path = require('path'); const {EventEmitter} = require('events'); +const {create} = require('axios'); const {nanoid} = require('nanoid'); +const axios = create({ + httpsAgent: new https.Agent({rejectUnauthorized: false, family: 4}), + httpAgent: new http.Agent({family: 4}), +}); + // helper to get a platform spec tmpfile const tmpfile = () => { return process.platform === 'win32' ? path.join(os.tmpdir(), `${nanoid()}.exe`) : path.join(os.tmpdir(), nanoid()); @@ -50,9 +57,11 @@ module.exports = (url, { // an error has occured .catch(error => { - error.message = `could not download ${url} [${error.response.status}] ${error.response.statusText}`; - debug(error.message); - // debug('%o', error); + // if error has a status code then rewrite message + if (error?.response?.status) { + error.message = `could not download ${url} [${error.response.status}] ${error.response.statusText}`; + } + download.error = error; download.emit('error', download.error); }) From 3c988bc658bc8ac05cbc3889509544001e9175b1 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 09:01:54 -0400 Subject: [PATCH 09/14] Update docker things --- CHANGELOG.md | 17 +++++++++++++++-- config.yml | 6 +++--- hooks/lando-setup-build-engine-darwin.js | 1 + hooks/lando-setup-build-engine-win32.js | 1 + utils/get-compose-x.js | 2 +- utils/get-config-defaults.js | 4 ++-- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e3941a7..23ee7a158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,22 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) -* Changed `download-x` to prefer `ipv4` [#165](https://github.com/lando/core/pull/165) +### New Feature + +* Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) +* Updated default Docker Compose version to `2.27.0` +* Updated default Docker Desktop version to `4.30.0` +* Updated default Docker Engine version to `26.1.1` +* Updated tested Docker Desktop range to `<=4.30` +* Updated tested Docker Engine range to `<27` + +### Bug Fixes + * Fixed unclear error when cancelling certain prompts + +### Internal + +* Changed `download-x` to prefer `ipv4` [#165](https://github.com/lando/core/pull/165) * Improved error handling on `download-x` [#165](https://github.com/lando/core/pull/165) -* Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) ## v3.21.0-beta.18 - [April 29, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.18) diff --git a/config.yml b/config.yml index f3074bcb8..21043c82e 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.26.1" + tested: "<=2.27.0" 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.29.0" + tested: "<=4.30.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 <27" - tested: "<=26.0.0" + tested: "<=26.1.1" link: linux: https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script diff --git a/hooks/lando-setup-build-engine-darwin.js b/hooks/lando-setup-build-engine-darwin.js index d0132affa..c0234cda9 100644 --- a/hooks/lando-setup-build-engine-darwin.js +++ b/hooks/lando-setup-build-engine-darwin.js @@ -7,6 +7,7 @@ const semver = require('semver'); const {color} = require('listr2'); const buildIds = { + '4.30.0': '149282', '4.29.0': '145265', '4.28.0': '139021', '4.27.2': '137060', diff --git a/hooks/lando-setup-build-engine-win32.js b/hooks/lando-setup-build-engine-win32.js index 3f23d48e9..861eaa81e 100644 --- a/hooks/lando-setup-build-engine-win32.js +++ b/hooks/lando-setup-build-engine-win32.js @@ -8,6 +8,7 @@ const {color} = require('listr2'); const {nanoid} = require('nanoid'); const buildIds = { + '4.30.0': '149282', '4.29.0': '145265', '4.28.0': '139021', '4.27.2': '137060', diff --git a/utils/get-compose-x.js b/utils/get-compose-x.js index 2c133b69e..c4a0be82d 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.26.1', userConfRoot = os.tmpdir()} = {}) => { +module.exports = ({orchestratorVersion = '2.27.0', 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 91c857e70..03ceef7f9 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -8,7 +8,7 @@ const os = require('os'); // Default config const defaultConfig = options => ({ orchestratorSeparator: '_', - orchestratorVersion: '2.26.1', + orchestratorVersion: '2.27.0', configSources: [], disablePlugins: [], dockerBin: require('../utils/get-docker-x')(), @@ -31,7 +31,7 @@ const defaultConfig = options => ({ // this governs both autosetup and the defaults of lando setup // @TODO: orchestrator works a bit differently because it predates lando.setup() we set it elsewhere setup: { - buildEngine: process.platform === 'linux' ? '26.0.0' : '4.29.0', + buildEngine: process.platform === 'linux' ? '26.1.1' : '4.30.0', buildEngineAcceptLicense: !require('is-interactive')(), commonPlugins: { '@lando/acquia': 'latest', From 49aabd70253c0af68d85b51cac3a3eb2a41a2792 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 09:16:49 -0400 Subject: [PATCH 10/14] Change buildx to buildkit and alias buildx to buildkit for 1337 image key --- CHANGELOG.md | 1 + components/l337-v4.js | 10 ++++----- docs/services/l337.md | 10 ++++----- examples/l337/.lando.yml | 45 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ee7a158..68ceeffc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Internal +* Added `buildkit` as an alias for `buildx` in `l337` service `image` key * Changed `download-x` to prefer `ipv4` [#165](https://github.com/lando/core/pull/165) * Improved error handling on `download-x` [#165](https://github.com/lando/core/pull/165) diff --git a/components/l337-v4.js b/components/l337-v4.js index 79a951dc2..296d21c9a 100644 --- a/components/l337-v4.js +++ b/components/l337-v4.js @@ -105,7 +105,7 @@ class L337ServiceV4 extends EventEmitter { // set top level required stuff this.id = id; this.appRoot = appRoot; - this.buildx = true; + this.buildkit = true; this.config = config; this.context = context; this.debug = debug; @@ -208,8 +208,8 @@ class L337ServiceV4 extends EventEmitter { // if we have a custom tag then set that if (data.tag) this.tag = data.tag; - // finally make sure we honor buildx disabling - if (require('../utils/is-disabled')(data.buildx ?? this.buildx)) this.buildx = false; + // finally make sure we honor buildkit disabling + if (require('../utils/is-disabled')((data.buildkit || data.buildx) ?? this.buildkit)) this.buildkit = false; } // just pushes the compose data directly into our thing @@ -467,7 +467,7 @@ class L337ServiceV4 extends EventEmitter { this.sshKeys = [...new Set(this.sshKeys.concat(keys))]; } - // add/merge in ssh stuff for buildx + // add/merge in ssh stuff for buildkit addSSH(ssh) { // if ssh is explicitly true then that implies agent true and keys true if (ssh === true) ssh = {agent: true, keys: true}; @@ -499,7 +499,7 @@ class L337ServiceV4 extends EventEmitter { // set state this.state = {IMAGE: 'BUILDING'}; // run with the appropriate builder - const success = this.buildx ? await bengine.buildx(imagefile, context) : await bengine.build(imagefile, context); + const success = this.buildkit ? await bengine.buildx(imagefile, context) : await bengine.build(imagefile, context); // eslint-disable-line max-len // augment the success info success.context = {imagefile, ...context}; // add the final compose data with the updated image tag on success diff --git a/docs/services/l337.md b/docs/services/l337.md index d9044e285..c1cbe6336 100644 --- a/docs/services/l337.md +++ b/docs/services/l337.md @@ -103,7 +103,7 @@ services: image: imagefile: "nginx:1.21" tag: "pirog/nginx:1.21" - buildx: true + buildkit: true ssh: false args: vibe: rising @@ -194,7 +194,7 @@ services: Array formatted `key=value` pairs are trimmed in both `key` and `value`. Args with no `value` are ignored as in `something` above. -### Buildx +### Buildkit If _for some reason_ you prefer to use the old pre-BuildKit image builder you can toggle this to `false`. @@ -205,13 +205,13 @@ services: # use the legacy builder example-1: api: 4 - buildx: false + buildkit: false type: l337 image: imagefile: nginx:1.21 ``` -Note that if you do `buildx: false` some image build features, specifically those in [Dockerfile 1.1.0+](https://docs.docker.com/build/dockerfile/release-notes/#110) and the [ssh](#ssh) features of this service, may not be available. +Note that if you do `buildkit: false` some image build features, specifically those in [Dockerfile 1.1.0+](https://docs.docker.com/build/dockerfile/release-notes/#110) and the [ssh](#ssh) features of this service, may not be available. You can also use `buildx` as an alias for `buildkit`. If you use both it will evaluate to `true` if either is `true`. Really just don't use both ;)! You probably should just ignore this setting unless you have a well understood reason to do otherwise. @@ -430,7 +430,7 @@ lando rebuild Here are some additional notes on this feature: * Passphrase protected keys can be used but only if added to your host `ssh-agent` _before_ image build -* This feature is not available if you set `buildx: false` +* This feature is not available if you set `buildkit: false` * The keys/agent are only available when explicitly mounted in a `RUN` instruction they **DO NOT** end up in the resulting image ### Steps diff --git a/examples/l337/.lando.yml b/examples/l337/.lando.yml index dd19ea329..1822cc7fc 100644 --- a/examples/l337/.lando.yml +++ b/examples/l337/.lando.yml @@ -146,6 +146,51 @@ services: owner: "nginx:nginx" permissions: "775" + # buildkit features + buildkit: + api: 4 + type: l337 + image: + buildkit: true + ssh: true + imagefile: | + # syntax=docker/dockerfile:1.7 + ARG VERSION=bookworm + FROM alpine AS build-env + WORKDIR /app + RUN touch /app/me + + FROM debian:$VERSION + ARG VERSION + + RUN echo $VERSION > image_version + RUN <> ~/.ssh/known_hosts + RUN --mount=type=ssh,id=keys git clone git@github.com:lando/lando.git /tmp/lando + RUN --mount=type=ssh,id=agent git clone git@github.com:lando/lando.git /tmp/more-lando + + # these are not universally supported yet + # ADD --keep-git-dir=true https://github.com/moby/buildkit.git#v0.10.1 /buildkit + # ADD --checksum=sha256:24454f830cdb571e2c4ad15481119c43b3cafd48dd869a9b2945d1036d1dc68d https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz /tmp + + COPY * /tmp + COPY --from=build-env /app /app2 + COPY --chown=55:mygroup file* /tmp/files + COPY --chown=bin file* /tmp/files2 + COPY --chown=1 file* /tmp/files3 + COPY --chown=10:11 file* /tmp/files3 + COPY --chown=myuser:mygroup --chmod=644 file* /tmp/files4 + + CMD sleep infinity + context: + - source: "file1" + destination: "/file7" + owner: "nginx:nginx" + permissions: "775" + # build-arg features build-args-1: api: 4 From 96821f16e25ad513232857a01cadfeeba24ac8fc Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 09:20:55 -0400 Subject: [PATCH 11/14] fix busted linx --- docs/lando-service.md | 8 ++++---- docs/services/l337.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/lando-service.md b/docs/lando-service.md index efa29cc5f..360493692 100644 --- a/docs/lando-service.md +++ b/docs/lando-service.md @@ -13,7 +13,7 @@ Generally you will want to use a more specific service like `type: php` but this * Using Docker Compose config from other projects * Need a service not currently provided by Lando itself -It implements a super-set of the [Docker Compose Version 3 Spec](https://docs.docker.com/compose/compose-file/compose-file-v3/) and _usually_ requires some [slight tweaks](#caveats) of existing Docker Compose configuration to work correctly. +It implements a super-set of the [Docker Compose Version 3 Spec](https://docs.docker.com/compose/compose-file/) and _usually_ requires some [slight tweaks](#caveats) of existing Docker Compose configuration to work correctly. Here is a birds-eye view of all its options: @@ -27,7 +27,7 @@ services: type: lando # these directly map to docker compose things - # see: https://docs.docker.com/compose/compose-file/compose-file-v3/ + # see: https://docs.docker.com/compose/compose-file/ # note that these are only available if you invoke the service directly services: {} networks: {} @@ -51,7 +51,7 @@ services: ## Services, Networks, Volumes -These three: `services,` `networks` and `volumes` map directly to the [Docker Compose Version 3 Spec](https://docs.docker.com/compose/compose-file/compose-file-v3/) which means that the below is a valid Landofile: +These three: `services,` `networks` and `volumes` map directly to the [Docker Compose Version 3 Spec](https://docs.docker.com/compose/compose-file/) which means that the below is a valid Landofile: **Landofile** ```yaml @@ -351,7 +351,7 @@ Since [Lando 3.14.0](https://github.com/lando/lando/releases/tag/v3.14.0) servic ## Overrides -Lando services are just an abstraction layer on top of the [Docker compose v3 file format](https://docs.docker.com/compose/compose-file/compose-file-v3/). What this means is that behind the scenes your Landofile is being translated into a *SHLOAD* of *SUPERNASTY* looking `docker-compose` files which are then being used to power your app. +Lando services are just an abstraction layer on top of the [Docker compose v3 file format](https://docs.docker.com/compose/compose-file/). What this means is that behind the scenes your Landofile is being translated into a *SHLOAD* of *SUPERNASTY* looking `docker-compose` files which are then being used to power your app. We give you access to the Docker Compose layer with the `overrides` key. diff --git a/docs/services/l337.md b/docs/services/l337.md index c1cbe6336..006961f97 100644 --- a/docs/services/l337.md +++ b/docs/services/l337.md @@ -14,7 +14,7 @@ The `l337` service is the lowest level `api: 4` service and it implements **L**a In high level terms it combines _service orchestration_ and _image specification_ into a single file format. -Specifically, it is a light superset around the [Docker Compose Version 3](https://docs.docker.com/compose/compose-file/compose-file-v3/) format that also uses the [Dockerfile](https://docs.docker.com/engine/reference/builder/) specification. +Specifically, it is a light superset around the [Docker Compose Version 3](https://docs.docker.com/compose/compose-file/) format that also uses the [Dockerfile](https://docs.docker.com/engine/reference/builder/) specification. This means that you _should_ be able to paste Docker Compose and/or Dockerfile compatible contents into your Landofile, add `api: 4` to each service and have it "just work". From 8132b264d27d6c45e06c6a888a73e9a8a639f64c Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 09:38:39 -0400 Subject: [PATCH 12/14] rebuild will now kill instead of stop --- CHANGELOG.md | 1 + lib/app.js | 7 ++++--- lib/compose.js | 7 ++++++- lib/router.js | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ceeffc1..0e15bdd7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * Added `buildkit` as an alias for `buildx` in `l337` service `image` key * Changed `download-x` to prefer `ipv4` [#165](https://github.com/lando/core/pull/165) +* Changed `rebuild` to `kill` instead of `stop` * Improved error handling on `download-x` [#165](https://github.com/lando/core/pull/165) ## v3.21.0-beta.18 - [April 29, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.18) diff --git a/lib/app.js b/lib/app.js index 239d67e92..079fac78f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -400,7 +400,7 @@ module.exports = class App { */ .then(() => this.events.emit('pre-rebuild')) // Stop app. - .then(() => this.stop()) + .then(() => this.stop(true)) // Uninstall app .then(() => this.uninstall()) // Repull/build components. @@ -526,9 +526,10 @@ module.exports = class App { * @alias app.stop * @fires pre_stop * @fires post_stop + * @param {Boolean} kill - Kill instead of stop * @return {Promise} A Promise. */ - stop() { + stop(kill = false) { // Stop it! this.log.info('stopping app...'); return initAndReport(this, 'stop') @@ -543,7 +544,7 @@ module.exports = class App { .then(() => this.events.emit('pre-stop')) // Stop components. - .then(() => this.engine.stop(this)) + .then(() => this.engine.stop({...this, kill})) /** * Event that runs after an app stop. diff --git a/lib/compose.js b/lib/compose.js index c9dbf1790..770b2e215 100644 --- a/lib/compose.js +++ b/lib/compose.js @@ -89,6 +89,11 @@ exports.build = (compose, project, opts = {}) => { */ exports.getId = (compose, project, opts = {}) => buildShell('ps', project, compose, opts); +/* + * Run docker compose kill + */ +exports.kill = (compose, project, opts = {}) => buildShell('kill', project, compose, opts); + /* * Run docker compose logs */ @@ -124,6 +129,6 @@ exports.run = (compose, project, opts = {}) => buildShell('exec', project, compo exports.start = (compose, project, opts = {}) => buildShell('up', project, compose, opts); /* - * Run docker compose kill + * Run docker compose stop */ exports.stop = (compose, project, opts = {}) => buildShell('stop', project, compose, opts); diff --git a/lib/router.js b/lib/router.js index 6c27d1487..c4986eabd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -129,5 +129,5 @@ exports.start = (data, compose) => retryEach(data, datum => compose('start', dat * Helper to route to stop command */ exports.stop = (data, compose, docker) => retryEach(data, datum => { - return (datum.compose) ? compose('stop', datum) : docker.stop(getContainerId(datum)); + return (datum.compose) ? compose(data.kill ? 'kill' : 'stop', datum) : docker.stop(getContainerId(datum)); }); From 80bc718f485ac59901096265713b401d44e0fdf6 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Thu, 9 May 2024 12:03:38 -0400 Subject: [PATCH 13/14] cl --- CHANGELOG.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5865f72e..fa722f3a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,19 +2,18 @@ ### New Features -* Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) - -* Added ability to autostart Docker Desktop for Windows from within WSL instances -* Improved method for locating and starting Docker Desktop on Windows +* Added ability to autostart Docker Desktop for Windows from within WSL instances [#164](https://github.com/lando/core/pull/164) +* Improved method for locating and starting Docker Desktop on Windows [#164](https://github.com/lando/core/pull/164) * Updated default Docker Compose version to `2.27.0` * Updated default Docker Desktop version to `4.30.0` * Updated default Docker Engine version to `26.1.1` * Updated tested Docker Desktop range to `<=4.30` * Updated tested Docker Engine range to `<27` +* Updated `sql-export.sh` to use `mariadb-dump` command (if available). [#148](https://github.com/lando/core/pull/148) ### Bug Fixes -* Fixed bug that caused Lando to be too impatient when starting Docker Desktop +* Fixed bug that caused Lando to be too impatient when starting Docker Desktop [#164](https://github.com/lando/core/pull/164) * Fixed unclear error when cancelling certain prompts ### Internal From 4b72dade538874b9323c50c910b93bdaae213a81 Mon Sep 17 00:00:00 2001 From: rtfm-47 Date: Thu, 9 May 2024 16:07:15 +0000 Subject: [PATCH 14/14] release v3.21.0-beta.19 generated by @lando/prepare-release-action --- CHANGELOG.md | 2 ++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa722f3a1..ce9623394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +## v3.21.0-beta.19 - [May 9, 2024](https://github.com/lando/core/releases/tag/v3.21.0-beta.19) + ### New Features * Added ability to autostart Docker Desktop for Windows from within WSL instances [#164](https://github.com/lando/core/pull/164) diff --git a/package-lock.json b/package-lock.json index 312e42093..fc19802fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@lando/core", - "version": "3.21.0-beta.18", + "version": "3.21.0-beta.19", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 0f23b4fdb..940d662b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@lando/core", "description": "The libraries that power all of Lando.", - "version": "3.21.0-beta.18", + "version": "3.21.0-beta.19", "author": "Mike Pirog @pirog", "license": "GPL-3.0", "repository": "lando/core",