Skip to content

Mount full codebase to web container - #314

Merged
tannerjfco merged 9 commits into
ddev:masterfrom
tannerjfco:docroot-mount-change
Jun 14, 2017
Merged

tannerjfco merged 9 commits into
ddev:masterfrom
tannerjfco:docroot-mount-change

Conversation

@tannerjfco

Copy link
Copy Markdown
Contributor

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-config tag 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:

composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction

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.

@tannerjfco tannerjfco self-assigned this Jun 13, 2017
@tannerjfco
tannerjfco requested a review from rfay June 13, 2017 20:24

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/ddevapp/templates.go Outdated
- "80"
- "{{ .mailhogport }}"
working_dir: "/var/www/html/docroot"
working_dir: "/var/www/html"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also change back to /var/www/html/docroot if we go that way.

- solr:$DDEV_HOSTNAME
```

## Providing custom nginx configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter that the right name of this file would be customization-extensibility.md? I don't think so.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tannerjfco
tannerjfco force-pushed the docroot-mount-change branch from fabaddc to 076287e Compare June 13, 2017 23:40

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannerjfco

Copy link
Copy Markdown
Contributor Author

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.

@tannerjfco
tannerjfco force-pushed the docroot-mount-change branch from 076287e to 14dd941 Compare June 14, 2017 17:12
@rfay

rfay commented Jun 14, 2017

Copy link
Copy Markdown
Member

Seems to me like this is fine.

  • Don't forget to push a bump to the web container tag before pulling.
  • It might be ok to change the assert in local_test.go to look for /var/www/html/docroot instead of just /var/www/html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants