Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wsl setup #279

Merged
merged 14 commits into from
Nov 27, 2024
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

### New Features & Improvements

* Added first class support to `lando setup` when run from `wsl` environments, see extended notes below
* Improved `docker` auto start on `linux` to use `GUI` authentication if available
* Improved messages and consistency between messages for `lando setup` tasks
* Improved pending setup task sort order

### Fixes

* Fixed bug in `l337` component preventing some context files from being `COPY`ed correclty on `win32`
* Fixed bug in `docker` launching causing it to not wait until `daemon` can accept connections
* Fixed bug causing `deferred` tasks to show as `Running` instead of `Deferred`
* Fixed bug causing case insenstive group membership matching to fail on `win32`

### Internal

* Introduced `process.landoPlatform` which is the same as `process.platform` but includes _our_ definition of `wsl` as a platform, see extended notes below

### Extended Notes

* Lando considers an environment a `wsl` environment only if `WSL_INTEROP` is on, otherwise it considers it a normal `linux` environment

## v3.23.13 - [November 23, 2024](https://github.com/lando/core/releases/tag/v3.23.13)

* Fixed bug causing metrics opt-out to not work in some situations [#277](https://github.com/lando/core/issues/277)
Expand Down
2 changes: 2 additions & 0 deletions bin/lando
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// set this first for all other downstream concerns
const dns = require('dns');

// Set DNS result order to IPv4 first
dns.setDefaultResultOrder('ipv4first');

Expand Down Expand Up @@ -126,6 +127,7 @@ cli.checkPerms();

// Lando cache stuffs
process.lando = 'node';
process.landoPlatform = require(`${COREBASE}/utils/is-wsl-interop`)() ? 'wsl' : process.platform;
process.landoTaskCacheName = '_.tasks.cache';
process.landoTaskCacheFile = path.join(cli.defaultConfig().userConfRoot, 'cache', process.landoTaskCacheName);
process.landoAppCacheFile = !_.isEmpty(appConfig) ? appConfig.composeCache : undefined;
Expand Down
3 changes: 3 additions & 0 deletions bin/lando.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\lando" %*
4 changes: 2 additions & 2 deletions components/l337-v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ class L337ServiceV4 extends EventEmitter {
file.instructions = file.url ? ['ADD'] : ['COPY'];
if (file.owner) file.instructions.push(`--chown=${file.owner}`);
if (file.permissions) file.instructions.push(`--chmod=${file.permissions}`);
file.instructions.push(file.url ?? path.join('.', file.target));
file.instructions.push(process.platform === 'win32' ? file.target : path.resolve('/', file.target));
file.instructions.push(file.url ?? path.posix.resolve('/', file.target));
file.instructions.push(path.posix.resolve('/', file.target));
file.instructions = file.instructions.join(' ');
}

Expand Down
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dockerSupportedVersions:
link:
darwin: https://docs.docker.com/desktop/install/mac-install/
win32: https://docs.docker.com/desktop/install/windows-install/
wsl: https://docs.docker.com/desktop/install/windows-install/
engine:
satisfies: ">=18 <28"
tested: "<=27.3.1"
Expand Down
29 changes: 4 additions & 25 deletions hooks/lando-autostart-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,17 @@ module.exports = async lando => {
const tasks = [{
title: 'It seems Docker is not running, trying to start it up...',
retry: {
tries: 25,
tries: 5,
delay: 1000,
},
task: async (ctx, task) => {
// 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',
message: `Enter computer password for ${lando.config.username} to start docker`,
validate: async (input, state) => {
const options = {debug, ignoreReturnCode: true, password: input};
const response = await require('../utils/run-elevated')(['echo', 'hello there'], options);
if (response.code !== 0) return response.stderr;
return true;
},
onCancel() {
process.emit('SIGINT');
},
});
}

try {
await lando.engine.daemon.up(false, ctx.password);
await lando.engine.daemon.up(false);
await lando.shell.sh([`"${lando.engine.daemon.docker}"`, 'network', 'ls']);
} catch (error) {
ctx.errors.push(error);
throw error;
debug('%j', error);
throw new Error('Could not automatically start Docker. Please manually start it to continue.');
}
},
}];
Expand Down
15 changes: 6 additions & 9 deletions hooks/lando-setup-build-engine-darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const getVersion = version => {
/*
* Helper to get docker compose v2 download url
*/
const getEngineDownloadUrl = (id = '170107') => {
const getEngineDownloadUrl = (id = '175267') => {
const arch = process.arch === 'arm64' ? 'arm64' : 'amd64';
return `https://desktop.docker.com/mac/main/${arch}/${id}/Docker.dmg`;
};
Expand Down Expand Up @@ -95,21 +95,18 @@ module.exports = async (lando, options) => {

// darwin install task
options.tasks.push({
title: `Downloading build engine`,
title: 'Downloading build engine',
id: 'setup-build-engine',
description: `@lando/build-engine (docker-desktop)`,
version: `docker-desktop ${install}`,
description: '@lando/build-engine (docker-desktop)',
version: `Docker Desktop ${install}`,
hasRun: async () => {
// start by looking at the engine install status
// @NOTE: is this always defined?
if (lando.engine.dockerInstalled === false) return false;

// if we get here let's make sure the engine is on
try {
await lando.engine.daemon.up();
const BuildEngine = require('../components/docker-engine');
const bengine = new BuildEngine(lando.config.buildEngine, {debug});
await bengine.info();
await lando.engine.daemon.up({max: 1, backoff: 1000});
return true;
} catch (error) {
lando.log.debug('docker install task has not run %j', error);
Expand Down Expand Up @@ -166,7 +163,7 @@ module.exports = async (lando, options) => {
result.download = ctx.download;

// finish up
task.title = 'Installed build engine to /Applications/Docker.app';
task.title = 'Installed build engine (Docker Desktop) to /Applications/Docker.app';
return result;
} catch (error) {
throw error;
Expand Down
15 changes: 12 additions & 3 deletions hooks/lando-setup-build-engine-linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ module.exports = async (lando, options) => {
title: `Installing build engine`,
id: 'setup-build-engine',
description: `@lando/build-engine (docker-engine)`,
version: `docker-engine ${version}`,
version: `Docker Engine ${version}`,
hasRun: async () => {
// start by looking at the engine install status
// @NOTE: is this always defined?
return lando.engine.dockerInstalled;
if (lando.engine.dockerInstalled === false) return false;

// if we get here let's make sure the engine is on
try {
await lando.engine.daemon.up({max: 1, backoff: 1000});
return true;
} catch (error) {
lando.log.debug('docker install task has not run %j', error);
return false;
}
},
canRun: async () => {
// throw if we cannot resolve a semantic version to a buildid
Expand Down Expand Up @@ -93,7 +102,7 @@ module.exports = async (lando, options) => {
result.download = ctx.download;

// finish up
task.title = 'Installed build engine to /usr/bin/docker';
task.title = 'Installed build engine (Docker Engine) to /usr/bin/docker';
return result;
} catch (error) {
throw error;
Expand Down
17 changes: 7 additions & 10 deletions hooks/lando-setup-build-engine-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const getVersion = version => {
/*
* Helper to get docker compose v2 download url
*/
const getEngineDownloadUrl = (id = '170107') => {
const getEngineDownloadUrl = (id = '175267') => {
const arch = process.arch === 'arm64' ? 'arm64' : 'amd64';
return `https://desktop.docker.com/win/main/${arch}/${id}/Docker%20Desktop%20Installer.exe`;
};
Expand Down Expand Up @@ -96,28 +96,25 @@ module.exports = async (lando, options) => {
const version = getVersion(options.buildEngine);

// cosmetics
const buildEngine = process.platform === 'linux' ? 'docker-engine' : 'docker-desktop';
const install = version ? `v${version}` : `build ${build}`;

// download url
const url = getEngineDownloadUrl(build);

// win32 install docker desktop task
options.tasks.push({
title: `Downloading build engine`,
title: 'Downloading build engine',
id: 'setup-build-engine',
description: `@lando/build-engine (${buildEngine})`,
version: `${buildEngine} ${install}`,
description: '@lando/build-engine (docker-desktop)',
version: `Docker Desktop ${install}`,
hasRun: async () => {
// start by looking at the engine install status
// @NOTE: is this always defined?
if (lando.engine.dockerInstalled === false) return false;

// if we get here let's make sure the engine is on
try {
await lando.engine.daemon.up();
const BuildEngine = require('../components/docker-engine');
const bengine = new BuildEngine(lando.config.buildEngine, {debug});
await bengine.info();
await lando.engine.daemon.up({max: 5, backoff: 1000});
return true;
} catch (error) {
lando.log.debug('docker install task has not run %j', error);
Expand Down Expand Up @@ -157,7 +154,7 @@ module.exports = async (lando, options) => {

// finish up
const location = process.env.ProgramW6432 ?? process.env.ProgramFiles;
task.title = `Installed build engine to ${location}/Docker/Docker!`;
task.title = `Installed build engine (Docker Desktop) to ${location}/Docker/Docker!`;
return result;
} catch (error) {
throw error;
Expand Down
Loading
Loading