terra-ops / terra-cli

The Terra Command Line Interface
http://terra.readthedocs.org
GNU General Public License v2.0
48 stars 17 forks source link

Unable to host symfony apps where there's a document root: other code is not in the container #60

Closed jonpugh closed 8 years ago

jonpugh commented 8 years ago

We can't host symfony apps right now that require files outside of the docroot.

Symfony normally uses a "web" docroot and puts minimal files in there, like https://github.com/jonpugh/aegir4/tree/master/web

The problem with this is that those files in web need to load code from the directory above.

Currently terra maps only the docroot directory to the container volume.

The other problem is that we can't dynamically change the NGINX file path from /usr/share/nginx//html.

This needs to change.

jonpugh commented 8 years ago

After poking around using "sed" to alter the NGINX config file at RUNtime, I am unable to make it work.

I'm starting to think we should just map the volume at /source and then create a symlink from /source/$DOCROOT to /usr/share/nginx/html

This would be a simpler solution i the end...

jonpugh commented 8 years ago

Found a blog post where they discovered you can use the variables directly in the conf file if you have certain NGINX modules installed.

https://docs.apitools.com/blog/2014/07/02/using-environment-variables-in-nginx-conf.html

Unfortunately it seems we would have to compile NGINX ourselves...

Going to look more into it.

john-binaryfeline commented 8 years ago

I would prefer the sed approach for a simple reason: in the future, terra should not be dictating the source code layout of the developer's project. If we use the sed approach, then the door is open to allowing developers using terra with various source code directory layouts. How do you feel about that?

jonpugh commented 8 years ago

That's the goal either way.

It works now by mapping a volume to whatever the "document_root" is set to in your app's .terra.yml. The problem is that there might be code above the document_root in the source code repo that is needed, which is not available inside the container.

The path to web code will be set as an environment variable per project, so we just need to figure out a way to get that environment variable into the server:location section of the nginx config.

jonpugh commented 8 years ago

Ahh symlinks!

jonpugh commented 8 years ago

To solve this I: