lando / lando

A development tool for all your projects that is fast, easy, powerful and liberating
https://lando.dev
GNU General Public License v3.0
4.08k stars 543 forks source link

docker-compose not working when starting Lando below project root #1007

Closed cboyden closed 5 years ago

cboyden commented 6 years ago

When I run lando start from a level below the project root, the container I've configured in my docker-compose.yml either doesn't start or isn't accessible to Lando.

Tell us about your setup

v3.0.0-beta.46 on Mac OSX 10.13.4

Tell us about your .lando.yml

name: obdrops
recipe: drupal7

compose:
  - docker-compose.yml

config:
  webroot: .
  php: '7.1'
  via: nginx

services: 
  database:
    type: mysql:5.7
  appserver:
    overrides:
      services:
        environment:
          PANOPOLY_BEHAT_SCREENSHOT_PATH: '/app/sites/default/files/screenshots'
    run:
      - "mkdir -p ~/.drush/site-aliases"
      - "ln -sf /drush/openberkeley.aliases.drushrc.php ~/.drush/site-aliases/openberkeley.drushrc.php"
  pma:
    type: phpmyadmin:4.6
    hosts:
      - database

tooling:
  behat:
    service: appserver
    description: Run behat tests locally.
    cmd: /app/profiles/openberkeley/openberkeley_tests/behat/bin/behat --config /app/profiles/openberkeley/openberkeley_tests/behat/behat.lando.yml

docker-compose.yml (stored in project root, same level as .lando.yml)

version: '3'

services:
  chromedriver:
    image: robcherry/docker-chromedriver:latest
    volumes:
      - ${LANDO_APP_ROOT}/:/app/
    expose:
      - "4444"
    environment:
      CHROMEDRIVER_WHITELISTED_IPS: ""
      CHROMEDRIVER_URL_BASE: "/wd/hub"
    security_opt:
      - seccomp:unconfined

Tell us about the command you were running

$ pwd
/Users/carolineboyden/Sites/test/obdrops/sites/default
$ lando start
Starting landoproxyhyperion5000gandalfedition_proxy_1 ... done
Starting obdrops_database_1  ... done
Starting obdrops_pma_1       ... done
Starting obdrops_appserver_1 ... done
Starting obdrops_nginx_1     ... done
Waiting until nginx service is ready...
Waiting until database service is ready...
Waiting until appserver service is ready...
Waiting until pma service is ready...
Waiting until chromedriver service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...

BOOMSHAKALAKA!!!

Your app has started up correctly.
Here are some vitals:

 NAME        obdrops
 LOCATION    /Users/carolineboyden/Sites/test/obdrops
 SERVICES    appserver, nginx, database, pma
 NGINX URLS  https://localhost:32775
             http://localhost:32776
             http://obdrops.localhost
             https://obdrops.localhost
 PMA URLS    http://localhost:32779

# Note the chromedriver service isn't listed.

$ lando stop
Killing obdrops_nginx_1     ... done
Killing obdrops_database_1  ... done
Killing obdrops_appserver_1 ... done
Killing obdrops_pma_1       ... done
App stopped!

$ cd ../../
$ pwd
/Users/carolineboyden/Sites/test/obdrops
$ lando rebuild
? Are you sure you want to rebuild? Yes
Removing obdrops_nginx_1        ... done
Removing obdrops_database_1     ... done
Removing obdrops_appserver_1    ... done
Removing obdrops_pma_1          ... done
Removing obdrops_chromedriver_1 ... done
Pulling chromedriver ... done
Pulling appserver    ... done
Pulling nginx        ... done
Pulling database     ... done
Pulling pma          ... done
chromedriver uses an image, skipping
appserver uses an image, skipping
nginx uses an image, skipping
database uses an image, skipping
pma uses an image, skipping
landoproxyhyperion5000gandalfedition_proxy_1 is up-to-date
Creating obdrops_pma_1          ... done
Creating obdrops_appserver_1    ... done
Creating obdrops_database_1     ... done
Creating obdrops_chromedriver_1 ... done
Creating obdrops_nginx_1        ... done
Waiting until nginx service is ready...
Waiting until appserver service is ready...
Waiting until pma service is ready...
Waiting until database service is ready...
Waiting until chromedriver service is ready...
Waiting until nginx service is ready...
Waiting until database service is ready...
Waiting until nginx service is ready...
Waiting until database service is ready...
Waiting until nginx service is ready...
Waiting until database service is ready...
Waiting until nginx service is ready...
Waiting until nginx service is ready...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   599    0   599    0     0   2076      0 --:--:-- --:--:-- --:--:--  2079
100 4482k  100 4482k    0     0  2637k      0  0:00:01  0:00:01 --:--:-- 5121k
 PHP configuration      :
 PHP OS                 :  Linux
 Drush script           :  /tmp/drush.phar
 Drush version          :  8.1.16
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

BOOMSHAKALAKA!!!

Your app has started up correctly.
Here are some vitals:

 NAME        obdrops
 LOCATION    /Users/carolineboyden/Sites/test/obdrops
 SERVICES    chromedriver, appserver, nginx, database, pma
 NGINX URLS  https://localhost:32790
             http://localhost:32791
             http://obdrops.localhost
             https://obdrops.localhost
 PMA URLS    http://localhost:32792

# Chromedriver service is now listed

Tell us generally about your bug

Should Lando be able to find the docker-compose.yml file relative to the .lando.yml file, rather than relative to where you run the start command? It's defined in the .lando.yml file. Or is there a way to write the .lando.yml file to force looking for docker-compose.yml relative to the project root?

jbertoen commented 6 years ago

try ./docker-compose.yml

cboyden commented 6 years ago

@jbertoen I get the same results when referencing ./docker-compose.yml instead of docker-compose.yml. If I run lando start from below the root directory, the chromedriver service on the container is either not started or not accessible.

jbertoen commented 6 years ago

Yeah that does seem like a bug, think I found it as well: plugins/lando-app/index.js, line 129:

      // Validate files
      var files = utils.validateFiles(_.get(app, 'config.compose', [], root));

If you dissect this utils.validateFiles(); would be called with only one parameter. Which would be the result of _.get(app, 'config.compose', [], root); The bug here is that _get() only has 3 parameters, and it is called with 4. And validateFiles() should be called with 2 parameters, and is called with 1. The second parameter of validateFiles() would be root. So it appears that there is a small typo here.

This might be the fix. Maybe @pirog or @dustinleblanc have an opinion about this?

      // Validate files
      var files = utils.validateFiles(_.get(app, 'config.compose', []), root);
jbertoen commented 6 years ago

Got a PR waiting for test results. Hopefully this would fix the issue. @cboyden could you try to use this branch of mine as a source for you lando setup and try if it works? To do that read this: https://docs.devwithlando.io/installation/installing.html#from-source Instead of using the lando/lando repo, use mine from the PR 😄

aleksijohansson commented 6 years ago

Any updates on this? Just ran into this issue today myself and it would be good to fix since with the drupal7 recipe one must be in the webroot (below the app root where .lando.yml is) to run drush commands.

pirog commented 5 years ago

This should be fixed in the forthcoming RC2