diff --git a/Dockerfile b/Dockerfile index bf71843..5381f40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.3.3-fpm-alpine3.9 +FROM php:7.3.4-fpm-alpine3.9 LABEL maintainer="Ric Harvey " diff --git a/README.md b/README.md index 479124a..fc8a5d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![pipeline status](https://gitlab.com/ric_harvey/nginx-php-fpm/badges/master/pipeline.svg) -![docker hub](https://img.shields.io/docker/pulls/richarvey/nginx-php-fpm.svg?style=flat) -![docker hub](https://img.shields.io/docker/stars/richarvey/nginx-php-fpm.svg?style=flat) +![docker hub](https://img.shields.io/docker/pulls/richarvey/nginx-php-fpm.svg?style=flat-square) +![docker hub](https://img.shields.io/docker/stars/richarvey/nginx-php-fpm.svg?style=flat-square) ## Overview This is a Dockerfile/image to build a container for nginx and php-fpm, with the ability to pull website code from git when the container is created, as well as allowing the container to push and pull changes to the code to and from git. The container also has the ability to update templated files with variables passed to docker in order to update your code and settings. There is support for lets encrypt SSL configurations, custom nginx configs, core nginx/PHP variable overrides for running preferences, X-Forwarded-For headers and UID mapping for local volume support. @@ -10,7 +10,7 @@ If you have improvements or suggestions please open an issue or pull request on ### Versioning | Docker Tag | Git Release | Nginx Version | PHP Version | Alpine Version | |-----|-------|-----|--------|--------| -| latest/1.6.7 | Master Branch |1.14.2 | 7.3.3 | 3.9 | +| latest/1.6.8 | Master Branch |1.14.2 | 7.3.4 | 3.9 | For other tags please see: [versioning](https://gitlab.com/ric_harvey/nginx-php-fpm/blob/master/docs/versioning.md) diff --git a/docs/config_flags.md b/docs/config_flags.md index b9cd31a..c1b8a6b 100644 --- a/docs/config_flags.md +++ b/docs/config_flags.md @@ -21,7 +21,6 @@ The following flags are a list of all the currently supported options that can b | Name | Description | |-------------------------|----------------------------------------------------------------------------------------------------------------| | WEBROOT | Change the default webroot directory from `/var/www/html` to your own setting | -| CONFIG_FOLDER | Change the default config directory from `/var/www/html/conf` to your own setting | | ERRORS | Set to 1 to display PHP Errors in the browser | | HIDE_NGINX_HEADERS | Disable by setting to 0, default behaviour is to hide nginx + php version in headers | | PHP_MEM_LIMIT | Set higher PHP memory limit, default is 128 Mb | @@ -32,7 +31,6 @@ The following flags are a list of all the currently supported options that can b | REAL_IP_HEADER | set to 1 to enable real ip support in the logs | | REAL_IP_FROM | set to your CIDR block for real ip in logs | | RUN_SCRIPTS | Set to 1 to execute scripts | -| SCRIPTS_FOLDER | Change the default script folder from `/var/www/html/scripts` to your won setting | | PGID | Set to GroupId you want to use for nginx (helps permissions when using local volume) | | PUID | Set to UserID you want to use for nginx (helps permissions when using local volume) | | REMOVE_FILES | Use REMOVE_FILES=0 to prevent the script from clearing out /var/www/html (useful for working with local files) | diff --git a/docs/nginx_configs.md b/docs/nginx_configs.md index 5e18f82..436a798 100644 --- a/docs/nginx_configs.md +++ b/docs/nginx_configs.md @@ -1,6 +1,5 @@ ## 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](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. -In addition, you can configure __CONFIG_FOLDER__ with your custome path. ## REAL IP / X-Forwarded-For Headers If you operate your container behind a load balancer, an ELB on AWS for example, you need to configure nginx to get the real IP and not the load balancer IP in the logs by using the X-Forwarded-For. We've provided some handy flags to let you do this. You need to set both of these to get this to work: diff --git a/docs/scripting_templating.md b/docs/scripting_templating.md index 30693a8..02ab715 100644 --- a/docs/scripting_templating.md +++ b/docs/scripting_templating.md @@ -1,6 +1,5 @@ ## 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://gitlab.com/ric_harvey/nginx-php-fpm/blob/master/docs/repo_layout.md) for more details on how to organise this. -In addition, you can configure __SCRIPT_FOLDER__ with your custome path. ## Using environment variables / templating To set the variables pass them in as environment variables on the docker command line. diff --git a/docs/versioning.md b/docs/versioning.md index 265a21d..8ec0ff8 100644 --- a/docs/versioning.md +++ b/docs/versioning.md @@ -15,17 +15,21 @@ The latest tag will always follow the master branch in git. the other versions w #### PHP 7.3 -| Docker Tag | PHP Version | Nginx Version | Alpine Version | Container Scripts | -|-----|-------|-----|--------|--------| -| 1.6.0 | 7.3.2 |1.14.2 | 3.9 | 0.3.8 | -| 1.6.1 | 7.3.2 |1.14.2 | 3.9 | 0.3.9 | -| 1.6.2 | 7.3.3 |1.14.2 | 3.9 | 0.3.10 | -| 1.6.3 | 7.3.3 |1.14.2 | 3.9 | 0.3.11 | -| 1.6.4 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 | -| 1.6.5 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 | -| 1.6.6 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 | -| 1.6.7 | 7.3.3 |1.14.2 | 3.9 | 0.3.13 | +| Docker Tag | PHP Version | Nginx Version | Alpine Version | Container Scripts | Notes | +|-----|-------|-----|--------|--------|----------| +| 1.6.0 | 7.3.2 |1.14.2 | 3.9 | 0.3.8 || +| 1.6.1 | 7.3.2 |1.14.2 | 3.9 | 0.3.9 || +| 1.6.2 | 7.3.3 |1.14.2 | 3.9 | 0.3.10 || +| 1.6.3 | 7.3.3 |1.14.2 | 3.9 | 0.3.11 || +| 1.6.4 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 || +| 1.6.5 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 || +| 1.6.6 | 7.3.3 |1.14.2 | 3.9 | 0.3.12 || +| 1.6.7 | 7.3.3 |1.14.2 | 3.9 | 0.3.13 | Broken | +| 1.6.8 | 7.3.4 |1.14.2 | 3.9 | 0.3.12 | Custom scripts rolled back | +These tags will be created on GitLab and as tags in docker hub. + +### Unmaintained tags: #### PHP 7.2 | Docker Tag | PHP Version | Nginx Version | Alpine Version | Container Scripts | @@ -41,9 +45,6 @@ The latest tag will always follow the master branch in git. the other versions w | 1.5.6 | 7.2.9 |1.14.0 | 3.7 | 0.3.8 | | 1.5.7 | 7.2.10 |1.14.0 | 3.7 | 0.3.8 | -These tags will be created on GitLab and as tags in docker hub. - -### Unmaintained tags: #### PHP 7.1 | Docker Tag | Git Release | Nginx Version | PHP Version | Alpine Version | Container Scripts | diff --git a/scripts/start.sh b/scripts/start.sh index 5140a27..04e789b 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -21,7 +21,7 @@ fi if [ ! -z "$WEBROOT" ]; then sed -i "s#root /var/www/html;#root ${WEBROOT};#g" /etc/nginx/sites-available/default.conf else - WEBROOT=/var/www/html + webroot=/var/www/html fi # Setup git variables @@ -34,14 +34,14 @@ if [ ! -z "$GIT_NAME" ]; then fi # Dont pull code down if the .git folder exists -if [ ! -d "${WEBROOT}/.git" ]; then +if [ ! -d "/var/www/html/.git" ]; then # Pull down code from git for our site! if [ ! -z "$GIT_REPO" ]; then # Remove the test index file if you are pulling in a git repo if [ ! -z ${REMOVE_FILES} ] && [ ${REMOVE_FILES} == 0 ]; then echo "skiping removal of files" else - rm -Rf ${WEBROOT}/* + rm -Rf /var/www/html/* fi GIT_COMMAND='git clone ' if [ ! -z "$GIT_BRANCH" ]; then @@ -57,7 +57,7 @@ if [ ! -d "${WEBROOT}/.git" ]; then GIT_COMMAND=${GIT_COMMAND}" https://${GIT_USERNAME}:${GIT_PERSONAL_TOKEN}@${GIT_REPO}" fi fi - ${GIT_COMMAND} ${WEBROOT} || exit 1 + ${GIT_COMMAND} /var/www/html || exit 1 if [ ! -z "$GIT_TAG" ]; then git checkout ${GIT_TAG} || exit 1 fi @@ -65,26 +65,22 @@ if [ ! -d "${WEBROOT}/.git" ]; then git checkout ${GIT_COMMIT} || exit 1 fi if [ -z "$SKIP_CHOWN" ]; then - chown -Rf nginx.nginx ${WEBROOT} + chown -Rf nginx.nginx /var/www/html fi fi fi -if [ -z "$CONFIG_FOLDER" ]; then - CONFIG_FOLDER=${WEBROOT}/conf -fi - # Enable custom nginx config files if they exist -if [ -f ${CONFIG_FOLDER}/nginx.conf ]; then - cp ${CONFIG_FOLDER}/nginx.conf /etc/nginx/nginx.conf +if [ -f /var/www/html/conf/nginx/nginx.conf ]; then + cp /var/www/html/conf/nginx/nginx.conf /etc/nginx/nginx.conf fi -if [ -f ${CONFIG_FOLDER}/nginx-site.conf ]; then - cp ${CONFIG_FOLDER}/nginx-site.conf /etc/nginx/sites-available/default.conf +if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then + cp /var/www/html/conf/nginx/nginx-site.conf /etc/nginx/sites-available/default.conf fi -if [ -f ${CONFIG_FOLDER}/nginx-site-ssl.conf ]; then - cp ${CONFIG_FOLDER}/nginx-site-ssl.conf /etc/nginx/sites-available/default-ssl.conf +if [ -f /var/www/html/conf/nginx/nginx-site-ssl.conf ]; then + cp /var/www/html/conf/nginx/nginx-site-ssl.conf /etc/nginx/sites-available/default-ssl.conf fi @@ -177,7 +173,7 @@ if [[ "$ENABLE_XDEBUG" == "1" ]] ; then fi fi fi -else +else if [ -f $XdebugFile ]; then echo "Disabling Xdebug" rm $XdebugFile @@ -193,22 +189,17 @@ if [ ! -z "$PUID" ]; then adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx -u ${PUID} nginx else if [ -z "$SKIP_CHOWN" ]; then - chown -Rf nginx.nginx ${WEBROOT} + chown -Rf nginx.nginx /var/www/html fi fi # Run custom scripts if [[ "$RUN_SCRIPTS" == "1" ]] ; then - - if [ -z "$SCRIPTS_FOLDER" ]; then - SCRIPTS_FOLDER=${WEBROOT}/scripts/ - fi - - if [ -d "${SCRIPTS_FOLDER}" ]; then + if [ -d "/var/www/html/scripts/" ]; then # make scripts executable incase they aren't - chmod -Rf 750 ${SCRIPTS_FOLDER}/*; sync; + chmod -Rf 750 /var/www/html/scripts/*; sync; # run scripts in number order - for i in `ls ${SCRIPTS_FOLDER}/`; do ${SCRIPTS_FOLDER}/$i ; done + for i in `ls /var/www/html/scripts/`; do /var/www/html/scripts/$i ; done else echo "Can't find script directory" fi @@ -216,13 +207,13 @@ fi if [ -z "$SKIP_COMPOSER" ]; then # Try auto install for composer - if [ -f "${WEBROOT}/composer.lock" ]; then + if [ -f "/var/www/html/composer.lock" ]; then if [ "$APPLICATION_ENV" == "development" ]; then composer global require hirak/prestissimo - composer install --working-dir=${WEBROOT} + composer install --working-dir=/var/www/html else composer global require hirak/prestissimo - composer install --no-dev --working-dir=${WEBROOT} + composer install --no-dev --working-dir=/var/www/html fi fi fi