From 4e9bf73fe24c6f1bddeebe9aff3134e0b0f3bcfd Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Tue, 16 Aug 2016 11:25:40 +0100 Subject: [PATCH] Adding custom nginx config support --- README.md | 3 +++ docs/repo_layout.md | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e53a806..0f8c18b 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,9 @@ To pull a repository and specify a branch add the GIT_BRANCH environment variabl sudo docker run -d -e 'GIT_NAME=full_name' -e 'GIT_USERNAME=git_username' -e 'GIT_REPO=github.com/project' -e 'SSH_KEY=BIG_LONG_BASE64_STRING_GOES_IN_HERE' -e 'GIT_BRANCH=stage' richarvey/nginx-php-fpm:latest ``` +### Custom Nginx Config files +Sometimes you need a custom config file for nginx to do rewrites or password protection, etc. For this reason we've included the ability to have custom nginx configs pulled directly from your git source. Please have a read of the [repo layout guidelines](docs/repo_layout.md) for more information. Its pretty simple to enable this, all you need to do is include a folder in the root of your repository called ```conf/nginx/``` within this folder you need to include a file called ```nginx-site.conf``` which will contain your default nginx site config. If you wish to have a custom file for SSL you simply include a file called ```nginx-site-ssl.conf``` in the same directory. These files will then be swapped in after you code is cloned. + ### Scripting There is often an occasion where you need to run a script on code to do a transformation once code lands in the container. For this reason we have developed scripting support. By including a scripts folder in your git repository and passing the __RUN_SCRIPTS=1__ flag to your command line the container will execute your scripts. Please see the [repo layout guidelines](https://github.com/ngineered/nginx-php-fpm/blob/master/docs/repo_layout.md) for more details on how to organise this. diff --git a/docs/repo_layout.md b/docs/repo_layout.md index dfecb8a..f953855 100644 --- a/docs/repo_layout.md +++ b/docs/repo_layout.md @@ -16,6 +16,10 @@ However if you wish to use scripting support you'll want to split code and scrip - repo root (/var/www/html) - src - your code here + - conf + - nginx + - default-site.conf + - default-site-ssl.conf - scripts - 00-firstscript.sh - 01-second.sh @@ -25,7 +29,7 @@ However if you wish to use scripting support you'll want to split code and scrip ### src If you use an alternative directory for your application root like the previous example of __src/__, you can use the __WEBROOT__ variable to instruct nginx that that is where the code should be served from. -``` docker run -e 'WEBROOT=/var/www/html/src/' -e OTHER_VARS ........``` +``` docker run -e 'WEBROOT=/var/www/html/src/' -e OTHER_VARS ........ ``` One example would be, if you are running craft CMS you'll end up with a repo structure like this: @@ -40,5 +44,8 @@ One example would be, if you are running craft CMS you'll end up with a repo str In this case __WEBROOT__ would be set as __/var/www/html/public__ +### conf +This directory is where you can put config files you call from your scripts. It is also home to the nginx folder where you can include custom nginx config files. + ### scripts Scripts are executed in order so its worth numbering them ```00,01,..,99``` to control their run order. Bash scripts are supported but, of course, you could install other run times in the first script then write your scripts in your preferred language.