diff --git a/examples/base/README.md b/examples/base/README.md index 39f606783..9de171f0a 100644 --- a/examples/base/README.md +++ b/examples/base/README.md @@ -43,17 +43,17 @@ Run the following commands to verify things work as expected ```bash # Should merge in all Landofiles correctly -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 # Should merge in all Landofiles correctly even if we are down a directory cd docker-compose -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 cd .. # Should load environment files from all Landofiles @@ -120,16 +120,16 @@ lando info --format json lando info --path "[0]" | grep service | wc -l | grep 1 # Should list this apps containers -lando list | grep landobase_log_1 -lando list | grep landobase_web_1 -lando list | grep landobase_web2_1 -lando list | grep landobase_web3_1 +lando list | grep lando-base-log-1 +lando list | grep lando-base-web-1 +lando list | grep lando-base-web2-1 +lando list | grep lando-base-web3-1 # Should output JSON in lando list without error lando list --format json # Should return a specified path when given with lando list -lando list --path "landobase" | grep landobase +lando list --path "lando-base" | grep lando-base # Should return logs without error lando logs @@ -166,33 +166,33 @@ docker ps --filter label=io.lando.container=TRUE -q | wc -l | grep 0 # Should rebuild the services without errors lando rebuild -y -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 # Should only rebuild the specified services lando rebuild -y --service web2 lando rebuild -y -s web2 -docker ps --latest | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --latest | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 lando rebuild -y --service web3 lando rebuild -y -s web3 -docker ps --latest | grep landobase_web3_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --latest | grep lando-base-web3-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 # Should restart the services without errors lando restart -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_log_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web2_1 -docker ps --filter label=com.docker.compose.project=landobase | grep landobase_web3_1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-log-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web2-1 +docker ps --filter label=com.docker.compose.project=lando-base | grep lando-base-web3-1 # Should have non-numeric keys in LANDO_INFO lando php info.php diff --git a/examples/l337/README.md b/examples/l337/README.md index 0feb783ba..b18db69c5 100644 --- a/examples/l337/README.md +++ b/examples/l337/README.md @@ -86,7 +86,7 @@ lando env | grep SERVICE | grep web lando whoami | grep nginx # should allow legacy moreHttpPorts to work like it does for v3 -docker inspect l337_web_1 | grep io.lando.http-ports | grep "80,443,8888" +docker inspect l337-web-1 | grep io.lando.http-ports | grep "80,443,8888" # should automatically set appMount if appRoot is volume mounted lando pwd | grep /site diff --git a/examples/lando-101/.lando.config.yml b/examples/lando-101/.lando.config.yml index 444e148e9..d232c1136 100644 --- a/examples/lando-101/.lando.config.yml +++ b/examples/lando-101/.lando.config.yml @@ -2,3 +2,6 @@ name: lando-101 recipe: lamp config: php: 7.4 + +plugins: + "@lando/core": "../../.." diff --git a/examples/lando-101/.lando.proxy.yml b/examples/lando-101/.lando.proxy.yml index 4ed3dcafe..6c0f37465 100644 --- a/examples/lando-101/.lando.proxy.yml +++ b/examples/lando-101/.lando.proxy.yml @@ -11,3 +11,6 @@ services: proxy: mailhog: - mail.lando-101.lndo.site + +plugins: + "@lando/core": "../../.." diff --git a/examples/lando-101/.lando.services.yml b/examples/lando-101/.lando.services.yml index 3fc978ba2..03967807b 100644 --- a/examples/lando-101/.lando.services.yml +++ b/examples/lando-101/.lando.services.yml @@ -8,3 +8,6 @@ services: portforward: true hogfrom: - appserver + +plugins: + "@lando/core": "../../.." diff --git a/examples/lando-101/.lando.tooling.yml b/examples/lando-101/.lando.tooling.yml index e097642fa..cabb4d815 100644 --- a/examples/lando-101/.lando.tooling.yml +++ b/examples/lando-101/.lando.tooling.yml @@ -15,3 +15,6 @@ tooling: phpcs: service: appserver cmd: /app/vendor/bin/phpcs + +plugins: + "@lando/core": "../../.." diff --git a/examples/lando-101/.lando.yml b/examples/lando-101/.lando.yml index 144bd6c4d..6c9183b83 100644 --- a/examples/lando-101/.lando.yml +++ b/examples/lando-101/.lando.yml @@ -1,2 +1,5 @@ name: lando-101 recipe: lamp + +plugins: + "@lando/core": "../../.." diff --git a/examples/networking/README.md b/examples/networking/README.md index 9a85eb05a..2912f4f76 100644 --- a/examples/networking/README.md +++ b/examples/networking/README.md @@ -35,21 +35,21 @@ Run the following commands to verify things work as expected ```bash # Should have the correct entries in /certs/cert.ext cd lamp -lando ssh -s appserver -c "cat /certs/cert.ext" | grep DNS.1 | grep -w appserver.landolamp.internal +lando ssh -s appserver -c "cat /certs/cert.ext" | grep DNS.1 | grep -w appserver.lando-lamp.internal lando ssh -s appserver -c "cat /certs/cert.ext" | grep DNS.2 | grep -w appserver lando ssh -s appserver -c "cat /certs/cert.ext" | grep DNS.3 | grep -w localhost lando ssh -s appserver -c "cat /certs/cert.ext" | grep lando-lamp.lndo.site cd .. && cd lemp -lando ssh -s placeholder -c "cat /certs/cert.ext" | grep DNS.1 | grep -w placeholder.landolemp.internal +lando ssh -s placeholder -c "cat /certs/cert.ext" | grep DNS.1 | grep -w placeholder.lando-lemp.internal lando ssh -s placeholder -c "cat /certs/cert.ext" | grep DNS.2 | grep -w placeholder lando ssh -s placeholder -c "cat /certs/cert.ext" | grep DNS.3 | grep -w localhost lando ssh -s placeholder -c "cat /certs/cert.ext" | grep placeholder.lando-lemp.lndo.site # Should have the correct internal hostname info cd lamp -lando info -s appserver | grep hostnames: | grep appserver.landolamp.internal +lando info -s appserver | grep hostnames: | grep appserver.lando-lamp.internal cd .. && cd lemp -lando info -s placeholder | grep hostnames: | grep placeholder.landolemp.internal +lando info -s placeholder | grep hostnames: | grep placeholder.lando-lemp.internal # Should be able to self connect from lamp cd lamp @@ -64,24 +64,24 @@ lando ssh -s placeholder -c "curl https://localhost" # Should be able to curl lemp from lamp at proxy addresses and internal hostnames cd lamp lando ssh -s appserver -c "curl http://lando-lemp.lndo.site" -lando ssh -s appserver -c "curl http://appserver_nginx.landolemp.internal" +lando ssh -s appserver -c "curl http://appserver_nginx.lando-lemp.internal" # lando ssh -s appserver -c "curl https://lando-lemp.lndo.site" -# lando ssh -s appserver -c "curl https://appserver_nginx.landolemp.internal" +# lando ssh -s appserver -c "curl https://appserver_nginx.lando-lemp.internal" lando ssh -s appserver -c "curl https://placeholder.lando-lemp.lndo.site" -lando ssh -s appserver -c "curl https://placeholder.landolemp.internal" +lando ssh -s appserver -c "curl https://placeholder.lando-lemp.internal" # Should be able to curl lamp from lemp at proxy addresses and internal hostname cd lemp lando ssh -s appserver -c "curl http://lando-lamp.lndo.site" -lando ssh -s appserver -c "curl http://appserver.landolamp.internal" +lando ssh -s appserver -c "curl http://appserver.lando-lamp.internal" # lando ssh -s appserver -c "curl https://lando-lamp.lndo.site" -# lando ssh -s appserver -c "curl https://appserver.landolamp.internal" +# lando ssh -s appserver -c "curl https://appserver.lando-lamp.internal" lando ssh -s placeholder -c "curl https://lando-lamp.lndo.site" -lando ssh -s placeholder -c "curl https://appserver.landolamp.internal" +lando ssh -s placeholder -c "curl https://appserver.lando-lamp.internal" # Should even be able to connect to a database in a different app cd lamp -lando ssh -s database -c "mysql -uroot -h database.landolemp.internal -e 'quit'" +lando ssh -s database -c "mysql -uroot -h database.lando-lemp.internal -e 'quit'" ``` Destroy tests diff --git a/examples/proxy/README.md b/examples/proxy/README.md index e19098310..3d86ca00e 100644 --- a/examples/proxy/README.md +++ b/examples/proxy/README.md @@ -78,12 +78,12 @@ curl http://object-format.lndo.site | grep X-Lando-Test-Ssl || echo $? | grep 1 curl -k https://object-format.lndo.site | grep X-Lando-Test-Ssl | grep on # Should generate a default certs config file and put it in the right place -docker exec landoproxyhyperion5000gandalfedition_proxy_1 cat /proxy_config/default-certs.yaml | grep certFile | grep /certs/cert.crt -docker exec landoproxyhyperion5000gandalfedition_proxy_1 cat /proxy_config/default-certs.yaml | grep keyFile | grep /certs/cert.key +docker exec landoproxyhyperion5000gandalfedition-proxy-1 cat /proxy_config/default-certs.yaml | grep certFile | grep /certs/cert.crt +docker exec landoproxyhyperion5000gandalfedition-proxy-1 cat /proxy_config/default-certs.yaml | grep keyFile | grep /certs/cert.key # Should generate proxy cert files and move them into the right location as needed -docker exec landoproxy_web3_1 cat /proxy_config/web3.landoproxy.yaml| grep certFile | grep "/lando/certs/web3.landoproxy.crt" -docker exec landoproxy_web3_1 cat /proxy_config/web3.landoproxy.yaml| grep keyFile | grep "/lando/certs/web3.landoproxy.key" +docker exec lando-proxy-web3-1 cat /proxy_config/web3.lando-proxy.yaml| grep certFile | grep "/lando/certs/web3.lando-proxy.crt" +docker exec lando-proxy-web3-1 cat /proxy_config/web3.lando-proxy.yaml| grep keyFile | grep "/lando/certs/web3.lando-proxy.key" ``` Destroy tests diff --git a/examples/scanner/README.md b/examples/scanner/README.md index ca0239f2b..2aea1a73f 100755 --- a/examples/scanner/README.md +++ b/examples/scanner/README.md @@ -23,11 +23,11 @@ Run the following commands to validate things are rolling as they should. ```bash # Should set 80,443 in io.lando.http-ports label by default -docker inspect landoscanner_scanme_1 | grep io.lando.http-ports | grep "80,443" +docker inspect lando-scanner-scanme-1 | grep io.lando.http-ports | grep "80,443" # Should add an extra port to io.lando.http-ports if specified -docker inspect landoscanner_moreports_1 | grep io.lando.http-ports | grep "80,443,8888" -docker inspect landoscanner_l337_1 | grep io.lando.http-ports | grep "80,443,8888" +docker inspect lando-scanner-moreports-1 | grep io.lando.http-ports | grep "80,443,8888" +docker inspect lando-scanner-l337-1 | grep io.lando.http-ports | grep "80,443,8888" ``` Destroy tests diff --git a/examples/services/.lando.yml b/examples/services/.lando.yml index 7ca74a436..97e7af58d 100644 --- a/examples/services/.lando.yml +++ b/examples/services/.lando.yml @@ -14,7 +14,7 @@ events: - cat /var/www/run_internal.txt | grep www-data - cat /run_as_root.txt | grep root - cat /var/www/run.txt | grep www-data - - /bin/sh -c 'echo "$LANDO_APP_PROJECT" | grep landoservices' + - /bin/sh -c 'echo "$LANDO_APP_PROJECT" | grep lando-services' # uncomment below to test out https://github.com/lando/core/issues/70 # this is commented out by default because of https://github.com/actions/runner/issues/241 # - bash /app/post-start.bash diff --git a/examples/services/README.md b/examples/services/README.md index 91f74247d..527835f19 100644 --- a/examples/services/README.md +++ b/examples/services/README.md @@ -39,8 +39,8 @@ lando rebuild -y # Should rerun build steps even if containers are manually removed and stuff lando destroy -y lando start -y -docker rm -f landoservices_nginx_1 -docker rm -f landoservices_appserver_1 +docker rm -f lando-services-nginx-1 +docker rm -f lando-services-appserver-1 lando start -y lando ssh -s appserver -c "vim --version" lando ssh -s appserver -c "cat /var/www/build.txt" diff --git a/hooks/app-run-v3-build-steps.js b/hooks/app-run-v3-build-steps.js index c449818d7..0bf22354f 100644 --- a/hooks/app-run-v3-build-steps.js +++ b/hooks/app-run-v3-build-steps.js @@ -35,10 +35,15 @@ module.exports = async (app, lando) => { // get v3 buildable services const buildServices = _.get(app, 'opts.services', app.services); + const dockerComposeServices = _(app.info) + .filter(info => info.type === 'docker-compose') + .map(info => info.service) + .value(); const buildV3Services = _(app.parsedV3Services) .filter(service => _.includes(buildServices, service.name)) .map(service => service.name) - .value(); + .value() + .concat(dockerComposeServices); app.log.debug('going to build v3 services if applicable', buildV3Services); // Make sure containers for this app exist; if they don't and we have build locks, we need to kill them diff --git a/lib/app.js b/lib/app.js index 239d67e92..023090f92 100644 --- a/lib/app.js +++ b/lib/app.js @@ -56,7 +56,7 @@ module.exports = class App { * @alias app.name */ this.name = require('../utils/slugify')(name); - this.project = require('../utils/docker-composify')(this.name); + this.project = this.name; this._serviceApi = 3; this._config = lando.config; this._defaultService = 'appserver'; @@ -272,14 +272,23 @@ module.exports = class App { // We should only need to initialize once, if we have just go right to app ready if (this.initialized) return this.events.emit('ready', this); // Get compose data if we have any, otherwise set to [] - const composeFiles = require('../utils/load-compose-files')(_.get(this, 'config.compose', []), this.root); - this.composeData = [new this.ComposeService('compose', {}, ...composeFiles)]; - // Validate and set env files - this.envFiles = require('../utils/normalize-files')(_.get(this, 'config.env_file', []), this.root); - // Log some things - this.log.verbose('initiatilizing app at %s...', this.root); - this.log.silly('app has config', this.config); - + return require('../utils/load-compose-files')( + _.get(this, 'config.compose', []), + this.root, + this._dir, + (composeFiles, outputFilePath) => + this.engine.getComposeConfig({compose: composeFiles, project: this.project, outputFilePath}), + ) + .then(composeFile => { + if (undefined !== composeFile) { + this.composeData = [new this.ComposeService('compose', {}, composeFile)]; + } + // Validate and set env files + this.envFiles = require('../utils/normalize-files')(_.get(this, 'config.env_file', []), this.root); + // Log some things + this.log.verbose('initiatilizing app at %s...', this.root); + this.log.silly('app has config', this.config); + }) /** * Event that allows altering of the app object right before it is * initialized. @@ -292,8 +301,9 @@ module.exports = class App { * @event pre_init * @property {App} app The app instance. */ - return loadPlugins(this, this._lando).then(() => this.events.emit('pre-init', this)) + .then(() => loadPlugins(this, this._lando)) + .then(() => this.events.emit('pre-init', this)) // Actually assemble this thing so its ready for that engine .then(() => { // Get all the services @@ -301,7 +311,7 @@ module.exports = class App { // Merge whatever we have thus far together this.info = require('../utils/get-app-info-defaults')(this); // finally just make a list of containers - const separator = _.get(this, '_config.orchestratorSeparator', '_'); + const separator = _.get(this, '_config.orchestratorSeparator', '-'); this.containers = _(this.info) .map(service => ([service.service, `${this.project}${separator}${service.service}${separator}1`])) .fromPairs() @@ -322,7 +332,43 @@ module.exports = class App { // Front load our app mounts this.add(new this.ComposeService('mounts', {}, {services: require('../utils/get-app-mounts')(this)}), true); // Then front load our globals - this.add(new this.ComposeService('globals', {}, {services: require('../utils/get-app-globals')(this)}), true); + const globalsData = _.merge( + {services: require('../utils/get-app-globals')(this)}, + { + services: + _.omitBy( + _.zipObject(_.keys(this.config.services), _.map( + this.config.services, + service => _.omitBy( + { + environment: _.omitBy({ + LANDO_WEBROOT_USER: service.api === 4 ? service.user : service.meUser, + LANDO_WEBROOT_GROUP: service.api === 4 ? service.user : service.meUser, + LANDO_MOUNT: service.api === 4 ? service.working_dir ?? service.appMount : service.appMount, + }, _.isNil), + }, + _.isEmpty, + ), + )), + _.isEmpty, + ), + }, + ); + _.forEach(globalsData.services, (service, name) => { + if ('docker-compose' !== _.find(this.info, {service: name})?.type) { + return; + } + service.volumes.push(`${this._config.userConfRoot}:/lando:cached`); + + if (!this.config.services[name]?.ssl) { + return; + } + + service.volumes.push( + `${path.join(path.join(this._config.userConfRoot, 'scripts'), 'add-cert.sh')}:/scripts/000-add-cert.sh`, + ); + }); + this.add(new this.ComposeService('globals', {}, globalsData), true); // Take the big dump of all our compose stuff this.compose = require('../utils/dump-compose-data')(this.composeData, this._dir); diff --git a/lib/compose.js b/lib/compose.js index c9dbf1790..ed4594f94 100644 --- a/lib/compose.js +++ b/lib/compose.js @@ -20,6 +20,7 @@ const composeFlags = { rm: '--rm', timestamps: '--timestamps', volumes: '-v', + outputFilePath: '-o', }; // Default options nad things @@ -33,6 +34,7 @@ const defaultOptions = { pull: {}, rm: {force: true, volumes: true}, up: {background: true, noRecreate: true, recreate: false, removeOrphans: true}, + config: {}, }; /* @@ -127,3 +129,8 @@ exports.start = (compose, project, opts = {}) => buildShell('up', project, compo * Run docker compose kill */ exports.stop = (compose, project, opts = {}) => buildShell('stop', project, compose, opts); + +/* + * Run docker compose config + */ +exports.config = (compose, project, opts = {}) => buildShell('config', project, compose, opts); diff --git a/lib/docker.js b/lib/docker.js index 125594068..fa77cdae1 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -69,7 +69,7 @@ module.exports = class Landerode extends Dockerode { /* * Returns a list of Lando containers */ - list(options = {}, separator = '_') { + list(options = {}, separator = '-') { return this.listContainers(options) // Filter out nulls and undefineds. .filter(_.identity) diff --git a/lib/engine.js b/lib/engine.js index ce3799e9c..04164ed88 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -28,7 +28,7 @@ module.exports = class Engine { this.dockerInstalled = this.daemon.docker !== false; // set the compose separator - this.separator = _.get(config, 'orchestratorSeparator', '_'); + this.separator = _.get(config, 'orchestratorSeparator', '-'); // Grab the supported ranges for our things this.supportedVersions = config.dockerSupportedVersions; @@ -488,5 +488,25 @@ module.exports = class Engine { // stop return this.engineCmd('stop', data); }; + + /** + * Get dumped docker compose config for compose files from project + * using a `compose` object with `{compose: compose, project: project, opts: opts}` + * + * @since 3.0.0 + * @param {Object} data Config needs a service within a compose context + * @param {Array} data.compose An Array of paths to Docker compose files + * @param {String} data.project A String of the project name (Usually this is the same as the app name) + * @param {String} [data.outputFilePath='/path/to/file.yml'] String to output path + * @param {Object} [data.opts] Options + * @return {Promise} A Promise. + * @example + * return lando.engine.stop(app); + */ + getComposeConfig(data) { + data.opts = {cmd: ['-o', data.outputFilePath]}; + delete data.outputFilePath; + return this.engineCmd('config', data); + }; }; diff --git a/lib/router.js b/lib/router.js index 6c27d1487..a6a7c67f9 100644 --- a/lib/router.js +++ b/lib/router.js @@ -131,3 +131,5 @@ exports.start = (data, compose) => retryEach(data, datum => compose('start', dat exports.stop = (data, compose, docker) => retryEach(data, datum => { return (datum.compose) ? compose('stop', datum) : docker.stop(getContainerId(datum)); }); + +exports.config = (data, compose) => retryEach(data, datum => compose('config', datum)); diff --git a/plugins/proxy/builders/_proxy.js b/plugins/proxy/builders/_proxy.js index 4a08d446a..0c833bd39 100644 --- a/plugins/proxy/builders/_proxy.js +++ b/plugins/proxy/builders/_proxy.js @@ -10,7 +10,7 @@ const getProxy = ({proxyCommand, proxyPassThru, proxyDomain, userConfRoot, versi return { services: { proxy: { - image: 'traefik:2.2.0', + image: 'traefik:2.10.7', command: proxyCommand.join(' '), environment: { LANDO_APP_PROJECT: '_lando_', @@ -18,6 +18,7 @@ const getProxy = ({proxyCommand, proxyPassThru, proxyDomain, userConfRoot, versi LANDO_PROXY_CONFIG_FILE: '/proxy_config/proxy.yaml', LANDO_PROXY_PASSTHRU: _.toString(proxyPassThru), LANDO_VERSION: version, + LANDO_DOMAIN: proxyDomain, }, networks: ['edge'], volumes: [ diff --git a/plugins/proxy/index.js b/plugins/proxy/index.js index 9ff6485cb..ca13fb606 100644 --- a/plugins/proxy/index.js +++ b/plugins/proxy/index.js @@ -14,7 +14,7 @@ const defaultConfig = { '/entrypoint.sh', '--log.level=DEBUG', '--api.insecure=true', - '--api.dashboard=false', + '--api.dashboard=true', '--providers.docker=true', '--entrypoints.https.address=:443', '--entrypoints.http.address=:80', diff --git a/tasks/ssh.js b/tasks/ssh.js index 84f50fa9e..61802f2c9 100644 --- a/tasks/ssh.js +++ b/tasks/ssh.js @@ -50,7 +50,7 @@ module.exports = (lando, app) => { // prefer appmount if (config.appMount) opts[1] = config.appMount; // fallback to working dir if available - if (!config.appMount && _.has(config, 'config.working_dir')) opts[0] = config.config.working_dir; + if (!config.appMount && _.has(config, 'working_dir')) opts[0] = config.working_dir; } // continue diff --git a/test/compose.spec.js b/test/compose.spec.js index d282600b0..0b599cdc9 100644 --- a/test/compose.spec.js +++ b/test/compose.spec.js @@ -202,4 +202,16 @@ describe('compose', () => { expect(stopResult).to.be.an('object'); }); }); + + describe('#config', () => { + it('should return the correct default options when not specified'); + it('#config should return an object.', () => { + const configResult = compose.config( + ['string1', 'string2'], + 'my_project', + myOpts, + ); + expect(configResult).to.be.an('object'); + }); + }); }); diff --git a/test/get-config-defaults.spec.js b/test/get-config-defaults.spec.js index b622c8eff..274f506e6 100644 --- a/test/get-config-defaults.spec.js +++ b/test/get-config-defaults.spec.js @@ -34,7 +34,7 @@ describe('get-config-defaults', () => { expect(_.hasIn(defaults, 'plugins')).to.equal(true); expect(_.hasIn(defaults, 'process')).to.equal(true); expect(_.hasIn(defaults, 'userConfRoot')).to.equal(true); - expect(_.get(defaults, 'orchestratorSeparator')).to.equal('_'); + expect(_.get(defaults, 'orchestratorSeparator')).to.equal('-'); expect(_.get(defaults, 'configSources')).to.be.an('array'); }); diff --git a/test/get-user.spec.js b/test/get-user.spec.js index d756b0b17..abf5c4216 100644 --- a/test/get-user.spec.js +++ b/test/get-user.spec.js @@ -29,6 +29,11 @@ describe('get-user', function() { expect(getUser('test-service', info)).to.equal('www-data'); }); + it('should return specified user if service is a "no-api" docker-compose service and user is specified', function() { + const info = [{service: 'test-service', type: 'docker-compose', meUser: 'custom-user'}]; + expect(getUser('test-service', info)).to.equal('custom-user'); + }); + it('should return "www-data" if service.api is 4 but no user is specified', function() { const info = [{service: 'test-service', api: 4}]; expect(getUser('test-service', info)).to.equal('www-data'); diff --git a/utils/get-app-info-defaults.js b/utils/get-app-info-defaults.js index 904110833..d3bd00329 100644 --- a/utils/get-app-info-defaults.js +++ b/utils/get-app-info-defaults.js @@ -4,6 +4,16 @@ const _ = require('lodash'); // adds required methods to ensure the lando v3 debugger can be injected into v4 things module.exports = app => _(app.services) - .map(service => ({service, urls: [], type: 'docker-compose', healthy: 'unknown'})) + .map(service => _.merge( + {service, urls: [], type: 'docker-compose', healthy: 'unknown'}, + _.omitBy( + { + meUser: _.get(app.config.services, service)?.meUser, + appMount: _.get(app.config.services, service)?.appMount, + hasCerts: _.get(app.config.services, service)?.ssl, + }, + _.isNil, + ), + )) .map(service => _.merge({}, service, _.find(app.info, {service: service.service}))) .value(); diff --git a/utils/get-app-mounts.js b/utils/get-app-mounts.js index 694ffedb3..521b4af70 100644 --- a/utils/get-app-mounts.js +++ b/utils/get-app-mounts.js @@ -6,7 +6,7 @@ module.exports = app => _(app.services) // Objectify .map(service => _.merge({name: service}, _.get(app, `config.services.${service}`, {}))) // Set the default - .map(config => _.merge({}, config, {app_mount: _.get(config, 'app_mount', 'cached')})) + .map(config => _.merge({}, config, {app_mount: _.get(config, 'app_mount', app.config.app_mount || 'cached')})) // Filter out disabled mountes .filter(config => config.app_mount !== false && config.app_mount !== 'disabled') // Combine together diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index 91c857e70..9c7f1f147 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -7,7 +7,7 @@ const os = require('os'); // Default config const defaultConfig = options => ({ - orchestratorSeparator: '_', + orchestratorSeparator: '-', orchestratorVersion: '2.26.1', configSources: [], disablePlugins: [], diff --git a/utils/get-user.js b/utils/get-user.js index f5b8b2094..ed42f7b87 100644 --- a/utils/get-user.js +++ b/utils/get-user.js @@ -7,8 +7,8 @@ module.exports = (name, info = []) => { if (!_.find(info, {service: name})) return 'www-data'; // otherwise get the service const service = _.find(info, {service: name}); - // if this is a "no-api" service eg type "docker-compose" also return www-data - if (!service.api && service.type === 'docker-compose') return 'www-data'; + // if this is a "no-api" service eg type "docker-compose" return meUser or www-data as default + if (!service.api && service.type === 'docker-compose') return service.meUser || 'www-data'; // otherwise return different things based on the api return service.api === 4 ? service.user || 'www-data' : service.meUser || 'www-data'; }; diff --git a/utils/load-compose-files.js b/utils/load-compose-files.js index f13bf4cec..3e1886d64 100644 --- a/utils/load-compose-files.js +++ b/utils/load-compose-files.js @@ -2,8 +2,24 @@ const _ = require('lodash'); const Yaml = require('./../lib/yaml'); +const path = require('path'); const yaml = new Yaml(); +const fs = require('fs'); -module.exports = (files, dir) => _(require('./normalize-files')(files, dir)) - .map(file => yaml.load(file)) - .value(); +// This just runs `docker compose --project-directory ${dir} config -f ${files} --output ${outputPaths}` to +// make all paths relative to the lando config root +module.exports = async (files, dir, landoComposeConfigDir, outputConfigFunction) => { + const composeFilePaths = _(require('./normalize-files')(files, dir)).value(); + if (_.isEmpty(composeFilePaths)) { + return {}; + } + + const outputFile = path.join(landoComposeConfigDir, 'resolved-compose-config.yml'); + + fs.mkdirSync(path.dirname(outputFile), {recursive: true}); + await outputConfigFunction(composeFilePaths, outputFile); + const result = yaml.load(outputFile); + fs.unlinkSync(outputFile); + + return result; +}; diff --git a/utils/parse-v3-services.js b/utils/parse-v3-services.js index cfed7f138..5707a322e 100644 --- a/utils/parse-v3-services.js +++ b/utils/parse-v3-services.js @@ -20,7 +20,7 @@ module.exports = (config, app) => _(config) app: app.name, confDest: path.join(app._config.userConfRoot, 'config', service.type.split(':')[0]), data: `data_${service.name}`, - home: app._config.home, + home: app.config.home || app._config.home, project: app.project, root: app.root, type: service.type.split(':')[0],