Repository navigation
Mount full codebase to web container - #314
Conversation
rfay
left a comment
There was a problem hiding this comment.
This mostly seems to work, but standard things that assume landing in the docroot by default (drush commands) are broken with this, so we should either use the docroot as the working directory or discuss it or something.
I'd definitely like to see an example with a simple nginx.conf in the docs, preferably a working starter-file.
I still haven't tried custom nginx, need to do that.
| - "80" | ||
| - "{{ .mailhogport }}" | ||
| working_dir: "/var/www/html/docroot" | ||
| working_dir: "/var/www/html" |
There was a problem hiding this comment.
I suspect this should be the docroot; It just used to be nice to be able to ddev ssh and immediately do a drush command. Also... ddev exec drush ... doesn't work now.
| err = app.Exec("web", true, "pwd") | ||
| assert.NoError(err) | ||
| out := stdout() | ||
| assert.Contains(out, "/var/www/html/docroot") |
There was a problem hiding this comment.
This would also change back to /var/www/html/docroot if we go that way.
| - solr:$DDEV_HOSTNAME | ||
| ``` | ||
|
|
||
| ## Providing custom nginx configuration |
There was a problem hiding this comment.
I don't think that this can be expressed as well in a paragraph as in an example. We probably need an examples directory here with a super-simple conf in it.
There was a problem hiding this comment.
Does it matter that the right name of this file would be customization-extensibility.md? I don't think so.
There was a problem hiding this comment.
I had intended to link to our configuration here but missed it. I have added that link, and provided links to the nginx wiki for additional examples.
fabaddc to
076287e
Compare
rfay
left a comment
There was a problem hiding this comment.
So far I'm unable to get the custom nginx-site.conf to work, so will check in with you in the morning.
|
|
||
| - Run `ddev config` for the site if it has not been used with ddev before. | ||
| - Create a file named "nginx-site.conf" in the ".ddev" directory for your site. | ||
| - Add your configurations to the "nginx-site.conf" file. You can optionally use the [default NGINX configuration provided by ddev](https://github.com/drud/docker.nginx-php-fpm-local/blob/master/files/etc/nginx/nginx-site.conf) as a reference or starting point. [Additional configuration examples](https://www.nginx.com/resources/wiki/start/#other-examples) and documentation are available at the [nginx wiki](https://www.nginx.com/resources/wiki/) |
There was a problem hiding this comment.
Link here is broken, https://github.com/drud/docker.nginx-php-fpm-local/blob/master/files/etc/nginx/nginx-site.conf, but I see it's only temporarily broken until that PR goes in.
|
I forgot to push an updated template-site-config tag for the web container, which is likely why the custom config didn't work for you. That update has been pushed now. |
076287e to
14dd941
Compare
|
Seems to me like this is fine.
|
The Problem:
#189 OP. Mounting only the docroot prevents code and assets above the docroot from being accessible to the web container. This can prevent a site from working entirely if it depends on code that resides above the docroot.
The Fix:
This introduces changes to mount the full codebase of the project instead of the docroot. The docroot value becomes a relative path that is provided to the web container as an environment variable. This env var is then used to set the docroot for nginx in the web container.
This will also include documentation changes to support overriding the nginx configuration file with one the user provides.
The Test:
To test this, you need to remove any pre-existing .ddev directory (minimally the docker-compose.yml). This also requires the
template-site-configtag of the web container be used for the test sites.To test this, you'll need a site that depends on code or assets that reside above the docroot. One way to get such a code base would be to create a drupal8 site using drupal-composer/drupal-project:
This creates as drupal8 site with a vendor directory above its docroot (named web). You should be able to ddev config/ddev start, and access a working drupal 8 installation. Previously, this project would produce fatal errors, as vendor dependencies would not be present on the web container. With this PR, it should work normally.
Automation Overview:
Existing tests have been updated for the mount volume / working directory change on the web container. I'm not sure there's a test for ddev, but I'm happy to consider suggestions. Most of the functionality change occurs with the web container, so I might look at a test over there.
Related Issue Link(s):
#189
#293
Release/Deployment notes:
This will require a new web container tag before merge.