lando / symfony

The Official Symfony Lando Plugin
https://docs.lando.dev/symfony/
GNU General Public License v3.0
6 stars 2 forks source link

Incorrect volume path when using nginx volume override #61

Open ttk opened 1 month ago

ttk commented 1 month ago

When adding an extra volume to the appserver_nginx container, the source directory on the host is wrong as it seems to be using the location of the underlying docker compose file location instead of my lando app root directory for the relative path. Best demonstrated by example:

Simple lando config:

name: test
recipe: symfony
config:
  via: nginx

services:
  appserver_nginx:
    overrides:
      volumes:
        - ./vendor:/app/vendor

Expected bind mounts: %LANDO_APP_ROOT%/vendor:/app/vendor

Actual bind mounts: %USERPROFILE%/.lando/compose/test:/app/vendor

I tested the same scenario with the nginx lando plugin directly, and it mounted the expected directory, so I think it something to do with the way the symfony lando plugin integrates with nginx.

$ lando version
v3.21.2

$ lando version --component symfony
v1.6.1

$ lando version --component nginx
v1.2.0

$ lando version --component php
v1.3.0

OS: Windows 11 (not sure if that matters.

reynoldsalec commented 1 month ago

@ttk I think this works as expected; the overrides documentation notes that it follows Docker Compose v3 syntax (https://docs.lando.dev/core/v3/services/lando.html#overrides) ...Docker volumes are referenced relatively from the build root AFAIK, which I believe is what you're experiencing. See https://docs.docker.com/reference/compose-file/services/#volumes for the relevant Docker Compose docs.

Essentially, once you get into overrides or making custom type: lando services, you're playing more directly with Docker Compose and Lando should respect those rules.

LMK if that makes sense or if I missed something!

ttk commented 1 month ago

@reynoldsalec What is confusing for me is why behavior is different specifically for the appserver_nginx service in this symfony recipe.

For nginx:

services:
  appserver_nginx:
    overrides:
      volumes:
        - ./vendor:/app/vendor

Gets converted to the following raw docker compose spec (note the relative path):

services:
  appserver_nginx:
    volumes:
      - './vendor:/app/vendor'

Whereas if I do the same for the appserver service in the same symfony recipe:

services:
  appserver:
    volumes:
      - './vendor:/app/vendor'

I get the follow raw docker compose spec, where the volume source path was translated to the absolute path to my lando app root.

services:
  appserver:
    volumes:
      - 'C:\tmp\landotest2\vendor:/app/vendor'

The translation of the relative paths to absolute path to my lando app root directory is what I expect for all services. I understand that using overrides is an advanced, low level feature that not a lot of people are going to use, but I figured it's worth reporting in case this is a bug.

reynoldsalec commented 1 month ago

Apologies for the late response here. I'm wondering if this is something Windows specific, which sadly is not my area of expertise.

I noticed that you're using quotes in the appserver example, does it operate differently if you remove those?