├── .gitignore ├── CHANGELOG.md ├── Makefile ├── Makefile-neam ├── README.md ├── composer.json ├── docs └── 71-building-docker-stack-images.md ├── images └── neam │ └── debian-php │ └── php-fpm-hhvm │ └── Dockerfile └── stacks └── neam ├── debian-php-nginx.database ├── docker-compose.yml ├── frontend │ └── www │ │ └── stack-hello │ │ ├── composer.json │ │ ├── index.php │ │ ├── mariadb.php │ │ ├── mongodb.php │ │ ├── mysql.php │ │ └── percona.php └── stack │ ├── README.md │ ├── mariadb │ ├── .db │ │ └── .gitignore │ └── run.sh │ ├── mongodb │ ├── .db │ │ └── .gitignore │ └── run.sh │ ├── mysql │ ├── .db │ │ └── .gitignore │ └── run.sh │ └── percona │ ├── .db │ └── .gitignore │ └── run.sh ├── debian-php-nginx.dna-project-base ├── .stack.nginx.Dockerfile ├── .stack.php.Dockerfile ├── docker-compose.yml └── stack │ ├── README.md │ ├── activate-nfs.sh │ ├── localdb-shell.sh │ ├── localdb │ ├── .db │ │ └── .gitignore │ ├── manage-permissions.sh │ ├── run.sh │ └── shell.sh │ ├── logs.sh │ ├── nginx │ ├── conf.d │ │ ├── .gitkeep │ │ └── app.conf │ ├── include │ │ ├── backend-location-defaults.conf │ │ └── location-defaults.conf │ └── run.sh │ ├── open-browser.sh │ ├── php │ └── images │ │ └── dna-project-base-debian-php │ │ ├── Dockerfile │ │ ├── php7.1 │ │ └── Dockerfile │ │ └── php7.2 │ │ └── Dockerfile │ ├── phphaproxy-stats.sh │ ├── recreate.sh │ ├── restart.sh │ ├── router-stats.sh │ ├── src │ ├── build.sh │ ├── git-pull-recursive.sh │ ├── install-core-deps.sh │ ├── install-deps.sh │ ├── install-local-deps.sh │ ├── reset-vendor.sh │ ├── update-autoload.sh │ └── update-core-deps.sh │ ├── start.sh │ ├── stop.sh │ └── tester-shell.sh └── debian-php-nginx ├── .stack.nginx.Dockerfile ├── .stack.php.Dockerfile ├── docker-compose.yml ├── frontend └── www │ └── stack-hello │ ├── index.php │ └── phpinfo.php └── stack ├── .gitignore ├── README.md ├── db-info.sh ├── docker-compose-production.docker-cloud.newrelic-agent.yml ├── docker-compose-production.docker-cloud.router.yml ├── docker-compose-production.docker-cloud.syslogger-papertrail.yml ├── docker-compose-production.docker-cloud.team-node-ssh-access.yml ├── docker-compose-production.docker-cloud.yml ├── docker-compose-production.yml ├── nginx ├── conf.d │ ├── .gitkeep │ ├── 00-basics.conf │ ├── app.conf │ └── php-fpm.conf ├── nginx.conf └── run.sh ├── php ├── conf.d-local │ └── local.ini ├── conf.d │ ├── .gitkeep │ ├── 00-basics.ini │ ├── app.ini │ └── xdebug.ini ├── hhvm │ ├── php.ini │ └── server.ini ├── images │ ├── Dockerfile │ ├── php7.1 │ │ └── Dockerfile │ └── php7.2 │ │ └── Dockerfile ├── inject-config-hhvm.sh ├── inject-config-php7.0.cli.sh ├── inject-config-php7.0.fpm.sh ├── inject-config-php7.0.sh ├── inject-config-php7.1.cli.sh ├── inject-config-php7.1.fpm.sh ├── inject-config-php7.1.sh ├── inject-config-php7.2.cli.sh ├── inject-config-php7.2.fpm.sh ├── inject-config-php7.2.sh ├── inject-config.sh ├── manage-permissions.sh ├── php-fpm │ ├── php-fpm.conf │ └── pool.d │ │ └── www.conf ├── php.ini ├── run.sh ├── shell.sh └── yet-unused │ └── newrelic.ini ├── shell.sh ├── src ├── set-writable-local-host-volumes.sh ├── set-writable-local.sh └── set-writable-remote.sh └── url.sh /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | config.json.bak 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | ## Project/Repository 5 | 6 | ### 1.0.0 (Not yet released) 7 | 8 | - Upg: Including Neam Stacks and supporting images 1.0.0 (see detailed changelog below) 9 | - Del: Removed docker-stack cli since it has no role in future docker stacks 10 | - Del: Removed schmunk42 images and stacks since they are maintained elsewhere 11 | - Del: Removed unmaintained neam images and stacks 12 | 13 | ### 0.4.0 (Released 2018-02-20) 14 | 15 | - Upg: Including Neam Stacks and supporting images 1.0.0 (see detailed changelog below) 16 | - Del: Removed generators directory since outdated and not used 17 | 18 | ### 0.3.0 (Released 2017-07-04) 19 | 20 | - Chg: Assumes native docker instead of docker via docker-machine/virtualbox for local dev 21 | - Upg: Including Neam Stacks and supporting images 0.7.0 (see detailed changelog below) 22 | - Enh: Clean-ups and clarifications 23 | 24 | ### 0.2.0 (Released 2016-06-09) 25 | 26 | - Upg: Updated docs to reflect Docker Cloud name change (Previously called Tutum) 27 | - Upg: Including Neam Stacks and supporting images 0.6.2 (see detailed changelog below) 28 | - Upg: Including updated stacks from Herzog Kommunikation - The Application Factory 29 | - Upg: Tested against Docker 1.11.1 and Docker Compose 1.7.1 30 | 31 | ### 0.1.0 (Released 2016-01-07) 32 | 33 | - Init: First official alpha release, as battle-tested in production by Neam Labs in several projects during more than 6 months (motin, schmunk42) 34 | - Init: Decided on a project/repository structure (motin, schmunk42) 35 | - Init: Including Neam Stacks and supporting images 0.6.1 (see detailed changelog below) 36 | 37 | ## Stacks and supporting images 38 | 39 | ### 1.0.0 (Not yet released) 40 | 41 | - Chg: [Neam Debian PHP/Nginx] PHP-FPM 7.2.5 added 42 | - Chg: [Neam Stacks] Decreased the amount of different images used in stacks 43 | - Chg: [Neam Stacks] Calling the shell container "shell" instead of "worker" 44 | - Enh: [Neam Stacks] Improvements and bug fixes 45 | - Chg: [Neam Debian PHP/Nginx] Added stretch backports to apt sources 46 | - Upg: [Neam Debian PHP/Nginx] Upgraded NodeJS 8.9 to 8.11 where present 47 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2018-05-09 19:40 (EEST) 48 | - Enh: [DNA Project Base] Added exiftool 10.79 to php images (installed from source) 49 | - Enh: [DNA Project Base] Added Google Cloud SDK to php images 50 | 51 | ### 0.8.0 (Released 2018-02-20) 52 | 53 | - Chg: [Neam Debian PHP/Nginx] Images are based on Debian stretch (current stable) instead of jessie (oldstable) 54 | - Chg: [Neam Debian PHP/Nginx] PHP-FPM 7.1.17 added 55 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 7.0.20 upgraded to 7.0.27 56 | - Chg: [Neam Debian PHP/Nginx] PHP-FPM 5.6 removed 57 | - Upg: [Neam Debian PHP/Nginx] HHVM removed since not in stable Debian, awaiting packages for stable Debian from HHVM project maintainers 58 | - Enh: [Neam Debian PHP/Nginx] Added php mods mbstring and mailparse 59 | - Upg: [Neam Debian PHP/Nginx] Upgraded NodeJS 4.8 to 8.9 where present 60 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2018-01-19 14:02 (EEST) 61 | - Env: [Neam Debian PHP/Nginx] Added build-essential to php images 62 | - Upg: [Neam Stacks] s3cmd upgraded from 1.5.0 to 1.6.1 (stable Debian) 63 | - Enh: [DNA Project Base] Added NodeJS 8.9 to php runtime images 64 | 65 | ### 0.7.0 (Released 2017-07-04) 66 | 67 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 7.0.7 upgraded to 7.0.20 68 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 5.6.20 upgraded to 5.6.30 69 | - Upg: [Neam Debian PHP/Nginx] HHVM 3.13.1 upgraded to 3.20.2 70 | - Enh: [Neam Debian PHP/Nginx] Including vhost in nginx logs so that multi-tenant deployment logs are easier to separate 71 | - Enh: [Neam Debian PHP/Nginx] Using Docker compose version 2 format, self-reconfiguring php-scaling locally, clarifications, tweaks 72 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2017-07-03 16:26 (UTC) 73 | - Upg: [Neam Stacks] NodeJS upgraded from 4.4 to 4.8 74 | - Enh: [Neam Stacks] Install pipe viewer (pv) to monitor progress of commands that pipes large files 75 | - Enh: [DNA Project Base] Include tmate for on-demand ssh access directly into containers 76 | - Enh: [DNA Project Base] Using PHP 7 by default in production 77 | - Enh: [DNA Project Base] MySQL upgraded from 5.6.27 to 5.7.11 78 | - Chg: [DNA Project Base] Renamed the file for specifying default local cli data profile from ".current-local-cli-data-profile" to ".default-local-cli-data-profile" 79 | - Enh: [DNA Project Base] Improvements and bug fixes 80 | 81 | ### 0.6.2 (Released 2016-06-07) 82 | 83 | - Enh: [Neam Debian PHP/Nginx] PHP-FPM 7.0.7 images built alongside PHP 5.6 images 84 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 5.6.17 upgraded to 5.6.20 85 | - Upg: [Neam Debian PHP/Nginx] HHVM 3.12.0 upgraded to 3.13.1 86 | - Upg: [Neam Debian PHP/Nginx] Composer updated to latest development version (includes important autoloader performance optimizations for PHP5.6 and 7) 87 | - Upg: [Neam Debian PHP/Nginx] Updated supporting deployment stacks to correspond to latest Docker Cloud best practices 88 | - Min: [Neam Debian PHP/Nginx] Enabling xdebug profiler requires local override in Neam Debian PHP/Nginx stack 89 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2016-06-07 07:33 (UTC) 90 | - Upg: [Neam Stacks] NodeJS upgraded from 0.10 to 4.4 91 | - Chg: [Neam Stacks] Removed php-app-tester, replaced by api-mock utility image 92 | - Chg: [Neam DNA Project Base] Stack tester shell now based on the production image 93 | - Enh: [Neam DNA Project Base] Tester shells for HHVM, PHP5 and PHP7.0 can be run in parallel 94 | - Enh: [Neam DNA Project Base] Stack commands for restart and recreate 95 | - Enh: [Neam DNA Project Base] Stack start command ensures that the publicly exposed ports are not in use already 96 | - Enh: [Neam DNA Project Base] Stack router stats commands (stack/router-stats.sh and stack/phphaproxy-stats.sh) 97 | - Enh: [Neam DNA Project Base] Clean-ups and smaller tweaks 98 | 99 | ### 0.6.1 (Released 2016-02-26) 100 | 101 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 5.6.14 upgraded to 5.6.17 102 | - Upg: [Neam Debian PHP/Nginx] HHVM 3.11.0 upgraded to 3.12.0 103 | - Enh: [Neam Debian PHP/Nginx] PHP-FPM uses the native MySQL driver (mysqlnd) by default 104 | - Enh: [Neam Debian PHP/Nginx] PHP-FPM xdebug extension included in image (disabled by default) 105 | - Enh: [Neam Debian PHP/Nginx] Publishing default xdebug ports locally by default 106 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2016-02-26 10:52 107 | 108 | ### 0.6.0 (Released 2016-01-07) 109 | 110 | - Enh: [Neam Debian PHP/Nginx] Made the debian-php-nginx stack include more components out-of-the-box 111 | - Enh: [Neam Debian PHP/Nginx] Added the debian-php-nginx.database stack that showcases how database engines are added to a stack 112 | - Enh: [Neam Debian PHP/Nginx] Retagged base neam docker images to clarify that the php images includes both php fpm and hhvm (together with their respective versions) 113 | - Upg: [Neam Debian PHP/Nginx] PHP-FPM 5.6.13 upgraded to 5.6.14 114 | - Upg: [Neam Debian PHP/Nginx] HHVM 3.9.1 upgraded to 3.11.0 (Includes PHP 7 language support) 115 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2016-02-26 10:52 116 | - Enh: [Neam Stacks] Documentation improvements and clean-up 117 | 118 | ### 0.5.0 (Released 2015-10-27) 119 | 120 | - Enh: [Neam Stacks] Using up-to-date version of haproxy image supporting Blue/Green zero-downtime deployments 121 | - Chg: [Neam Stacks] Orientation towards multi-tenancy deployments, where each tenant has access to their own database 122 | - Enh: [Neam Stacks] Added sample tutum maintenance stack configurations (for newrelic, distributed logging and enabling node ssh access) 123 | - Enh: [Neam Stacks] Performance and stability tweaks 124 | 125 | ### 0.4.0 (Released 2015-10-06) 126 | 127 | - Enh: [Neam Debian PHP/Nginx] Enabled use of HHVM as an alternative to PHP-FPM 128 | - Chg: [Neam Debian PHP/Nginx] Using HHVM instead of PHP-FPM by default (PHP-FPM can still be re-enabled on a per-project bases in case issues with HHVM are encountered) 129 | - Upg: [Neam Debian PHP/Nginx] PHP 5.6.9 upgraded to 5.6.13 130 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2015-10-06 16:16 131 | - Enh: [Neam Stacks] DNA Project Base stack includes a local database container with persistent local data enabled by default 132 | - Enh: [Neam Stacks] Sane default Xdebug configuration provided. Xdebug verified to work with current stack. 133 | - Min: [Neam Stacks] Tweaks to stack documentation 134 | 135 | ### 0.3.0 (Released 2015-08-13) 136 | 137 | - Chg: [Neam Debian PHP/Nginx] A revert to official debian base image (instead of tutum's debian image as in 0.2.0) 138 | - Upg: [Neam Debian PHP/Nginx] PHP 5.6.7 upgraded to 5.6.9 139 | - Enh: [Neam Stacks] Lockdown of haproxy image to a working one (pending refactoring to use the latest upstream master) 140 | - Chg: [Neam Stacks] A reliance on tutum’s docker exec support for shell access instead of using a separate worker container with a ssh service running 141 | - Enh: [Neam DNA Project Base] Added some shorthand-scripts (start, stop, setup, logs, open-browser) to interact with the stack 142 | - Min: [Neam Stacks] Omitting PHP warning about $HTTP_RAW_POST_DATA 143 | - Min: [Neam Stacks] Added Xdebug default enable setting env var to php images 144 | - Upg: [Neam Debian PHP/Nginx] All debian packages updated as per 2015-08-13 10:53 145 | - Min: [Neam Stacks] Some tweaks to stack documentation 146 | 147 | ### 0.2.0 (Released 2015-04-23) 148 | 149 | - Chg: [Neam Debian PHP/Nginx] Based on Tutum's jessie image with optional ssh support 150 | - Enh: [Neam DNA Project Base] Tons of performance and reliability tweaks after having battle-tested the stack in production 151 | - Enh: [Neam DNA Project Base] Added php-xsl to dna project base php image 152 | 153 | ### 0.1.0 (In development between 2015-03-15 and 2015-04-23, never tagged as 0.1.0) 154 | 155 | - Init: Initial version 156 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all build default release schmunk 2 | 3 | default: build 4 | 5 | all: neam 6 | 7 | neam: 8 | $(MAKE) -f Makefile-neam $@ ; \ 9 | -------------------------------------------------------------------------------- /Makefile-neam: -------------------------------------------------------------------------------- 1 | 2 | # workaround for default action 3 | neam: build-neam 4 | 5 | build-neam: neam.debian-php neam.stack-images neam.dna-project-base 6 | 7 | neam.debian-php: 8 | echo "Building debian-php images" 9 | docker build -t neam/debian-php:fpm-7.0.27-hhvm-3.x.y images/neam/debian-php/php-fpm-hhvm 10 | docker build --build-arg PHP_PACKAGE_NAME_VERSION=7.1 --build-arg PHP_VERSION=7.1.17 -t neam/debian-php:fpm-7.1.17-hhvm-3.x.y images/neam/debian-php/php-fpm-hhvm 11 | docker build --build-arg PHP_PACKAGE_NAME_VERSION=7.2 --build-arg PHP_VERSION=7.2.5 -t neam/debian-php:fpm-7.2.5-hhvm-3.x.y images/neam/debian-php/php-fpm-hhvm 12 | 13 | neam.stack-images: 14 | echo "Building debian-php-nginx stack base php image" 15 | docker build -t neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack stacks/neam/debian-php-nginx/stack/php/images 16 | docker build --build-arg PHP_PACKAGE_NAME_VERSION=7.1 -t neam/debian-php:fpm-7.1.17-hhvm-3.x.y-for-debian-php-nginx-stack stacks/neam/debian-php-nginx/stack/php/images/php7.1 17 | docker build --build-arg PHP_PACKAGE_NAME_VERSION=7.2 -t neam/debian-php:fpm-7.2.5-hhvm-3.x.y-for-debian-php-nginx-stack stacks/neam/debian-php-nginx/stack/php/images/php7.2 18 | 19 | neam.dna-project-base: export version=1.0.0 20 | neam.dna-project-base: neam.stack-images 21 | echo "Building neam.dna-project-base stack base php image" 22 | docker build -t neam/dna-project-base-debian-php:$(version) stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php 23 | docker build -t neam/dna-project-base-debian-php:$(version)-php7.1 stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php/php7.1 24 | docker build -t neam/dna-project-base-debian-php:$(version)-php7.2 stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php/php7.2 25 | 26 | release-neam: export version=1.0.0 27 | release-neam: neam.dna-project-base 28 | echo "Pushing neam images to Docker Hub..." 29 | docker push neam/debian-php:fpm-7.0.27-hhvm-3.x.y 30 | docker push neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 31 | docker push neam/dna-project-base-debian-php:$(version) 32 | docker push neam/debian-php:fpm-7.1.17-hhvm-3.x.y 33 | docker push neam/debian-php:fpm-7.1.17-hhvm-3.x.y-for-debian-php-nginx-stack 34 | docker push neam/dna-project-base-debian-php:$(version)-php7.1 35 | docker push neam/debian-php:fpm-7.2.5-hhvm-3.x.y 36 | docker push neam/debian-php:fpm-7.2.5-hhvm-3.x.y-for-debian-php-nginx-stack 37 | docker push neam/dna-project-base-debian-php:$(version)-php7.2 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Docker Stack 2 | ============ 3 | 4 | Stacks and images used in production by [Neam Labs](http://neamlabs.com) in order to Develop, Build, Test, Deploy and Maintain PHP+NodeJS-based web applications. 5 | 6 | Published as open-source so that they can be used and adapted by other projects, or act as a reference point and inspiration when you set up your own Docker-based stack architecture. 7 | 8 | The stacks and images in this repo are verified to work well for both local development and high performance multi-node setups deployed at AWS using [Docker Cloud](https://cloud.docker.com) and [constantly tweaked to be faster and more reliable](./CHANGELOG.md). 9 | 10 | Requirements 11 | ------------ 12 | 13 | * docker 17.12.0-ce (17.12.0-ce+ recommended) 14 | * docker-compose 1.18.0 (1.18.0+ recommended) 15 | * git 16 | 17 | Why use a Docker-based stack in the first place? 18 | ------------------- 19 | 20 | Docker stacks allow development teams to weave together web applications written in a any combination of PHP, NodeJS, Java and Python, utilizing Dockerized services (databases, mail servers, task runners, message queues etc). 21 | 22 | ## For the developer 23 | 24 | As a member of a developer team, the Docker-based stack enables you to ditch Vagrant/Puppet/Chef while still maintaining a cross-platform local development workflow similar to the powerful `npm install` + `npm start` combo for javascript-based apps: 25 | 26 | docker-compose run php composer install 27 | docker-compose up 28 | 29 | Thus, in any team or project where multiple developers are involved, less time and hassle is necessary to get the project software running locally, and all team members will be running the same versions of the underlying operating system packages. 30 | 31 | ## For dev-ops 32 | 33 | Maintain a best-practice Docker-based "one-process-per-container" stack and development workflows for your [12-factor web apps](http://12factor.net/). 34 | 35 | The stack can then be deployed to any docker host/swarm or orchestrated via [Docker Cloud](https://cloud.docker.com), providing a high degree of dev/prod parity. 36 | 37 | Stacks 38 | ---------------- 39 | 40 | - [Debian PHP/Nginx](stacks/neam/debian-php-nginx/stack/README.md) 41 | - [Debian PHP/Nginx + Database (LEMP)](stacks/neam/debian-php-nginx/stack/README.md) 42 | - [DNA Project Base Stack (Based on Debian PHP/Nginx + Database)](stacks/neam/debian-php-nginx.dna-project-base/stack/README.md) 43 | 44 | Building Docker Stack Images locally 45 | ------------------------------------ 46 | 47 | - [Building Docker Stack Images](docs/71-building-docker-stack-images.md) 48 | 49 | FAQ 50 | --- 51 | 52 | ## What is a stack? 53 | 54 | > A stack is a collection of services that make up an application in a specific environment. A stack file is a file in YAML format that define one or more services. The YAML reference is documented here. 55 | 56 | > A stack is a convenient way to automate the deployment of multiple services that are linked to each other, without the need to define one by one. 57 | 58 | > As stack files also define environment variables and related environment-specific configuration, it is recommended to use one stack file per environment (dev, test, prod...). 59 | 60 | License 61 | ------- 62 | 63 | MIT 64 | 65 | Acknowledgements 66 | ---------------- 67 | 68 | This repository was co-created with [schmunk42](https://github.com/schmunk42), who is nowadays maintaining docker stack images at [dmstr](https://github.com/dmstr?utf8=%E2%9C%93&q=docker&type=&language=). 69 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "neam/docker-stack", 3 | "description": "Toolkit for maintaining a Docker-based \"one-process-per-container\" stack for 12-factor web apps.", 4 | "keywords": ["php", "docker", "php-fpm", "nginx", "local-dev"], 5 | "homepage": "https://github.com/neam/docker-stack", 6 | "type": "library", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Fredrik Wollsén", 11 | "email": "fredrik@neam.se", 12 | "homepage": "http://www.neam.se" 13 | }, 14 | { 15 | "name": "Tobias Munk", 16 | "email": "schmunk@usrbin.de", 17 | "homepage": "http://diemeisterei.de" 18 | }, 19 | { 20 | "name": "Github Contributors", 21 | "homepage": "https://github.com/neam/docker-stack/graphs/contributors" 22 | }, 23 | { 24 | "name": "Open Source Community" 25 | } 26 | ], 27 | "require": { 28 | }, 29 | "require-dev": { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/71-building-docker-stack-images.md: -------------------------------------------------------------------------------- 1 | ## Building images 2 | 3 | To build the collections of images for the stacks, you can run `make` as follows 4 | 5 | time make neam 6 | 7 | or by specifying the `Makefile` directly 8 | 9 | time make -f Makefile-neam build-neam 10 | 11 | ## Release/distribute/push images 12 | 13 | To push the collections of images for the stacks, you can run `make` as follows 14 | 15 | time make -f Makefile-neam release-neam 16 | 17 | If you do not have write access to these repositories, copy the related build and release make-targets and adapt them to tag the images properly to your registry. 18 | -------------------------------------------------------------------------------- /images/neam/debian-php/php-fpm-hhvm/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.0.27, HHVM 3.x.y) built for PHP/Nginx-based docker-stacks 2 | # =============================================================== 3 | # docker build -f Dockerfile -t neam/debian-php:fpm-7.0.27-hhvm-3.x.y . 4 | # docker push neam/debian-php:fpm-7.0.27-hhvm-3.x.y 5 | 6 | FROM debian:stretch 7 | 8 | # defaults, use other values at build-time to produce an image with other versions 9 | ARG PHP_VERSION=7.0.27 10 | ARG PHP_PACKAGE_NAME_VERSION=7.0 11 | ARG HHVM_VERSION=3.x.y 12 | 13 | MAINTAINER Fredrik Wollsén 14 | 15 | # Prepare Debian environment 16 | ENV DEBIAN_FRONTEND noninteractive 17 | 18 | # Performance optimization - see https://gist.github.com/jpetazzo/6127116 19 | # this forces dpkg not to call sync() after package extraction and speeds up install 20 | RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup 21 | # we don't need and apt cache in a container 22 | RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache 23 | 24 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 25 | RUN apt-get update && \ 26 | apt-get upgrade -y -q # 2018-05-09 19:40 27 | 28 | # PHP 7.1 sources 29 | RUN if [ "${PHP_PACKAGE_NAME_VERSION}" = "7.1" ]; then \ 30 | apt-get install -y -q apt-transport-https lsb-release ca-certificates curl && \ 31 | curl -L -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \ 32 | sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \ 33 | apt-get update; fi 34 | 35 | # PHP 7.2 sources 36 | RUN if [ "${PHP_PACKAGE_NAME_VERSION}" = "7.2" ]; then \ 37 | apt-get install -y -q apt-transport-https lsb-release ca-certificates curl && \ 38 | curl -L -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \ 39 | sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \ 40 | apt-get update; fi 41 | 42 | # Install specific version of PHP-FPM (if not available - show what versions were available in debian stretch at the moment of APT_DOCKER_CACHE_TRIGGER above) 43 | RUN apt-get install -y -q \ 44 | php${PHP_PACKAGE_NAME_VERSION}-fpm=${PHP_VERSION}* \ 45 | || (echo "php${PHP_PACKAGE_NAME_VERSION}-cli \n $(apt-cache show php${PHP_PACKAGE_NAME_VERSION}-cli | grep -i version)" && \ 46 | echo "php${PHP_PACKAGE_NAME_VERSION}-fpm \n $(apt-cache show php${PHP_PACKAGE_NAME_VERSION}-fpm | grep -i version)" && \ 47 | exit 1) 48 | 49 | # HHVM binaries 50 | #RUN apt-get install -y -q \ 51 | # hhvm=${HHVM_VERSION}* \ 52 | # || (echo "hhvm \n $(apt-cache show hhvm | grep -i version)" && \ 53 | # exit 1) 54 | 55 | # Clean apt caches 56 | RUN apt-get clean && \ 57 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 58 | 59 | # Set environment var PHP_PACKAGE_NAME_VERSION 60 | ENV PHP_PACKAGE_NAME_VERSION ${PHP_PACKAGE_NAME_VERSION} 61 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for local development 2 | version: '2' 3 | services: 4 | 5 | # The nginx server for serving static files directly, cached contents via the memcached server and php files via the php service 6 | web: 7 | image: nginx:1.7 8 | links: 9 | - phphaproxy 10 | - phpfiles 11 | volumes: 12 | - .:/app:rw 13 | ports: 14 | - "80" 15 | environment: 16 | NGINX_ERROR_LOG_LEVEL: 'notice' 17 | working_dir: '/app' 18 | command: "/app/stack/nginx/run.sh" 19 | 20 | # HA Proxy for php service scaling 21 | phphaproxy: 22 | image: dockercloud/haproxy:1.5.1 23 | links: 24 | - phpha 25 | ports: 26 | - "9000" 27 | # Publish stats port 28 | - "1936" 29 | environment: 30 | MODE: tcp 31 | TIMEOUT: connect 500, client 120000, server 120000 32 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 33 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 34 | # Necessary for auto-scaling using Docker-for-Mac 35 | volumes: 36 | - /var/run/docker.sock:/var/run/docker.sock 37 | 38 | # The elastically scalable php service for interpreting php code without access to /files 39 | phpha: 40 | image: neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 41 | links: 42 | - mailcatcher 43 | - redisphpsessionhandler 44 | - mysql 45 | #- mariadb # Commented due to https://github.com/docker-library/mariadb/issues/30 46 | - percona 47 | - mongodb 48 | volumes: 49 | - .:/app:rw 50 | ports: 51 | - "9000" 52 | - "9089" # Xdebug 53 | environment: 54 | TCP_PORTS: '9000' 55 | DISPLAY_PHP_ERRORS: 'on' 56 | LOAD_XDEBUG_EXTENSION: '1' 57 | XDEBUG_DEFAULT_ENABLE: 'off' 58 | RUNNING_LOCALLY: '1' 59 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 60 | PHP_PACKAGE_NAME_VERSION: '7.0' 61 | env_file: 62 | - .env 63 | working_dir: '/app' 64 | command: "/app/stack/php/run.sh" 65 | 66 | # The redis service used as the PHP session handler for all containers 67 | redisphpsessionhandler: 68 | image: redis 69 | ports: 70 | - "6379" 71 | 72 | # The single-node php service for interpreting php code with read-write access to user-generated files 73 | # (to support file uploads and other local file manipulations) 74 | phpfiles: 75 | image: neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 76 | links: 77 | - mailcatcher 78 | - redisphpsessionhandler 79 | - mysql 80 | #- mariadb # Commented due to https://github.com/docker-library/mariadb/issues/30 81 | - percona 82 | - mongodb 83 | volumes: 84 | - .:/app:rw 85 | - .files:/files:rw 86 | ports: 87 | - "9000" 88 | - "9089" # Xdebug 89 | environment: 90 | TCP_PORTS: '9000' 91 | DISPLAY_PHP_ERRORS: 'on' 92 | LOAD_XDEBUG_EXTENSION: '0' 93 | XDEBUG_DEFAULT_ENABLE: 'off' 94 | RUNNING_LOCALLY: '1' 95 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 96 | PHP_PACKAGE_NAME_VERSION: '7.0' 97 | env_file: 98 | - .env 99 | working_dir: '/app' 100 | command: "/app/stack/php/run.sh" 101 | 102 | # Local MySQL database server to mimic a cloud database 103 | mysql: 104 | image: mysql:5.6.27 105 | volumes: 106 | - ./stack/mysql/.db/mysql:/var/lib/mysql:rw 107 | - ./stack/mysql/:/stack/mysql:rw 108 | ports: 109 | - "3306" 110 | environment: 111 | MYSQL_ROOT_PASSWORD: "local-mysql-pass" 112 | command: "/stack/mysql/run.sh" 113 | 114 | # Local MariaDB database server to mimic a cloud database 115 | mariadb: 116 | image: mariadb:10.1.10 117 | volumes: 118 | - ./stack/mariadb/.db/mysql:/var/lib/mysql:rw 119 | - ./stack/mariadb/:/stack/mariadb:rw 120 | ports: 121 | - "3306" 122 | environment: 123 | MYSQL_ROOT_PASSWORD: "local-mariadb-pass" 124 | command: "/stack/mariadb/run.sh" 125 | 126 | # Local Percona database server to mimic a cloud database 127 | percona: 128 | image: percona:5.6.27 129 | volumes: 130 | - ./stack/percona/.db/mysql:/var/lib/mysql:rw 131 | - ./stack/percona/:/stack/percona:rw 132 | ports: 133 | - "3306" 134 | environment: 135 | MYSQL_ROOT_PASSWORD: "local-percona-pass" 136 | command: "/stack/percona/run.sh" 137 | 138 | # Local Mongo database server to mimic a cloud database 139 | # NOTICE: because MongoDB uses memory mapped files it is not possible to use it through vboxsf to your host (vbox bug). // https://hub.docker.com/_/mongo/ 140 | # Instead, the solution described on http://www.diogogmt.com/running-mongodb-with-docker-and-compose/ is used below 141 | mongodbdata: 142 | image: mongo:3.2.0 143 | volumes: 144 | - /data/db 145 | command: --break-mongo 146 | mongodb: 147 | image: mongo:3.2.0 148 | volumes_from: 149 | - mongodbdata 150 | volumes: 151 | - ./stack/mongodb/:/stack/mongodb:rw 152 | ports: 153 | - "27017" 154 | command: --smallfiles --rest --auth 155 | 156 | # Mailcatcher server for catching outgoing email when not in production 157 | mailcatcher: 158 | image: nisenabe/mailcatcher 159 | expose: 160 | - "25" 161 | ports: 162 | - "1080" 163 | 164 | # A container to run worker/administration commands locally - start a shell by running stack/shell.sh 165 | shell: 166 | image: neam/dna-project-base-debian-php:1.0.0 167 | links: 168 | - mysql 169 | - mariadb 170 | - percona 171 | - mongodb 172 | volumes: 173 | - .:/app:rw 174 | - .files:/files:rw 175 | - ../.git:/.git 176 | - ~/.composer:/root/.composer 177 | - ~/.gitconfig:/root/.gitconfig 178 | - ~/.ssh:/root/.ssh:ro 179 | environment: 180 | DISPLAY_PHP_ERRORS: 'off' 181 | LOAD_XDEBUG_EXTENSION: '1' 182 | XDEBUG_DEFAULT_ENABLE: 'off' 183 | RUNNING_LOCALLY: '1' 184 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 185 | PHP_PACKAGE_NAME_VERSION: '7.0' 186 | working_dir: '/app' 187 | command: "/app/stack/php/shell.sh" 188 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/frontend/www/stack-hello/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "neam/debian-nginx-php.database.stack-hello", 3 | "require": { 4 | "mongodb/mongodb": "^0.2.0" 5 | }, 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Fredrik Wollsen", 10 | "email": "fredrik@neam.se" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/frontend/www/stack-hello/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/frontend/www/stack-hello/mariadb.php: -------------------------------------------------------------------------------- 1 | > .env 64 | 65 | Then, fire up the stack locally: 66 | 67 | docker-compose up -d 68 | 69 | Visit the stack-hello pages by visiting the URL returned by: 70 | 71 | stack/url.sh web 80 - /stack-hello/ 72 | 73 | > Hint: On OSX, you can open the url directly from a terminal session: 74 | 75 | open $(stack/url.sh web 80 - /stack-hello/) 76 | 77 | To scale the PHP "ha" service: 78 | 79 | docker-compose scale phpha=3 80 | 81 | ## Frontend and backend example 82 | 83 | Create the index php files expected by the default configuration: 84 | 85 | mkdir -p frontend/www 86 | mkdir -p backend/www 87 | echo ' frontend/www/index.php 88 | echo ' backend/www/index.php 89 | 90 | Visit the below returned urls in your browser (frontend and backend respectively): 91 | 92 | stack/url.sh 93 | stack/url.sh web 80 - /backend/ 94 | 95 | > Hint: On OSX, you can open the url directly from a terminal session: 96 | > 97 | > stack/open-browser.sh 98 | > stack/open-browser.sh /backend/ 99 | 100 | ## Local Extras 101 | 102 | The local stack include optional containers that emulate upstream services outside of your control. Simply comment them out if you do not need them. 103 | 104 | ### Explanation of the extra local containers 105 | 106 | * `mysql` - Runs a local MySQL server 107 | * `mariadb` - Runs a local MariaDB server 108 | * `percona` - Runs a local Percona server 109 | * `mongodb` - Runs a local MongoDB server 110 | * `mailcatcher` - Runs a mailcatcher SMTP server 111 | 112 | ### Corresponding service in production 113 | 114 | * `mysql` - A cloud MySQL database service such as Amazon RDS, Rackspace CloudDB etc 115 | * `mariadb` - A cloud MariaDB database service 116 | * `percona` - A cloud Percona database service 117 | * `mongodb` - A cloud MongoDB database service 118 | * `mailcatcher` - An SMTP service such as Gmail, Amazon Simple Mail Service, Foo etc 119 | 120 | ### Using MySQL 121 | 122 | In order to connect to your local database from your work station, use the following credentials: 123 | 124 | User: admin 125 | Password: local-mysql-pass 126 | 127 | Connect to the host and port given by: 128 | 129 | stack/db-info.sh mysql mysql 130 | 131 | ### Using MariaDB 132 | 133 | In order to connect to your local database from your work station, use the following credentials: 134 | 135 | User: admin 136 | Password: local-mariadb-pass 137 | 138 | Connect to the host and port given by: 139 | 140 | stack/db-info.sh mysql mariadb 141 | 142 | ### Using Percona 143 | 144 | In order to connect to your local database from your work station, use the following credentials: 145 | 146 | User: admin 147 | Password: local-percona-pass 148 | 149 | Connect to the host and port given by: 150 | 151 | stack/db-info.sh mysql percona 152 | 153 | ### Using MongoDB 154 | 155 | In order to connect to your local database from your work station, use the following credentials: 156 | 157 | User: ? 158 | Password: local-mongodb-pass 159 | 160 | Connect to the host and port given by: 161 | 162 | stack/db-info.sh mongodb mongodb 27017 163 | 164 | ## Using mailcatcher 165 | 166 | Configure your app to send emails using `mailcatcher` as the SMTP server against port 25. 167 | 168 | The emails will show up in the web frontend accessible on the url given by the following command: 169 | 170 | stack/url.sh mailcatcher 1080 171 | 172 | ## Customization 173 | 174 | ### Configuration 175 | 176 | Optionally, generate your project php/nginx base configuration based on composer.json metadata: [Follow these instructions](../../generators/server-config-generator/README.md) 177 | 178 | Customize your php/nginx configuration by changing the files in your project's `stack/nginx/` and `stack/php/` directories. 179 | 180 | To use PHP-FPM instead of HHVM, comment the "hhvm"-related lines almost at the bottom of your project's `stack/php/run.sh`, and uncomment the "php-fpm" line. 181 | 182 | Also, because HHVM seems to alter the SCRIPT_NAME and DOCUMENT_ROOT params from nginx, add the following to your index.php file: 183 | 184 | // HHVM SCRIPT_NAME difference vs php-fpm workaround 185 | if (defined('HHVM_VERSION')) { 186 | $_SERVER['DOCUMENT_ROOT'] = $_SERVER['NGINX_DOCUMENT_ROOT']; 187 | $_SERVER['SCRIPT_NAME'] = $_SERVER['NGINX_SCRIPT_NAME']; 188 | $_SERVER['PHP_SELF'] = $_SERVER['NGINX_SCRIPT_NAME']; 189 | } 190 | 191 | And make sure to keep the following in your nginx location blocks (see docker-stack/stacks/debian-php-nginx/stack/nginx/conf.d/app.conf): 192 | 193 | # for hhvm 194 | fastcgi_keep_conn on; 195 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 196 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 197 | 198 | ### Advanced 199 | 200 | Compare this stack to the stack found at `../debian-php-nginx.database` for an example of how to add one or many database engine(s) to your stack 201 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mariadb/.db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mariadb/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Script to workaround docker-machine/boot2docker OSX host volume issues: https://github.com/docker-library/mysql/issues/99 5 | 6 | echo '* Working around permission errors locally by making sure that "mysql" uses the same uid and gid as the host volume' 7 | TARGET_UID=$(stat -c "%u" /var/lib/mysql) 8 | echo '-- Setting mysql user to use uid '$TARGET_UID 9 | usermod -o -u $TARGET_UID mysql || true 10 | TARGET_GID=$(stat -c "%g" /var/lib/mysql) 11 | echo '-- Setting mysql group to use gid '$TARGET_GID 12 | groupmod -o -g $TARGET_GID mysql || true 13 | echo 14 | echo '* Starting MariaDB' 15 | chown -R mysql:root /var/run/mysqld/ 16 | /docker-entrypoint.sh mysqld --user=mysql --console 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mongodb/.db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mongodb/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Script to workaround docker-machine/boot2docker OSX host volume issues: https://github.com/docker-library/mysql/issues/99 5 | 6 | echo '* Working around permission errors locally by making sure that "mongodb" uses the same uid and gid as the host volume' 7 | TARGET_UID=$(stat -c "%u" /data/db) 8 | echo '-- Setting mongodb user to use uid '$TARGET_UID 9 | usermod -o -u $TARGET_UID mongodb || true 10 | TARGET_GID=$(stat -c "%g" /data/db) 11 | echo '-- Setting mongodb group to use gid '$TARGET_GID 12 | groupmod -o -g $TARGET_GID mongodb || true 13 | echo 14 | echo '* Starting MongoDB' 15 | #chown -R mongodb:root /var/run/mongodbd/ 16 | /entrypoint.sh mongodbd --user=mongodb --console 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mysql/.db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/mysql/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Script to workaround docker-machine/boot2docker OSX host volume issues: https://github.com/docker-library/mysql/issues/99 5 | 6 | echo '* Working around permission errors locally by making sure that "mysql" uses the same uid and gid as the host volume' 7 | TARGET_UID=$(stat -c "%u" /var/lib/mysql) 8 | echo '-- Setting mysql user to use uid '$TARGET_UID 9 | usermod -o -u $TARGET_UID mysql || true 10 | TARGET_GID=$(stat -c "%g" /var/lib/mysql) 11 | echo '-- Setting mysql group to use gid '$TARGET_GID 12 | groupmod -o -g $TARGET_GID mysql || true 13 | echo 14 | echo '* Starting MySQL' 15 | chown -R mysql:root /var/run/mysqld/ 16 | /entrypoint.sh mysqld --user=mysql --console 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/percona/.db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.database/stack/percona/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Script to workaround docker-machine/boot2docker OSX host volume issues: https://github.com/docker-library/mysql/issues/99 5 | 6 | echo '* Working around permission errors locally by making sure that "mysql" uses the same uid and gid as the host volume' 7 | TARGET_UID=$(stat -c "%u" /var/lib/mysql) 8 | echo '-- Setting mysql user to use uid '$TARGET_UID 9 | usermod -o -u $TARGET_UID mysql || true 10 | TARGET_GID=$(stat -c "%g" /var/lib/mysql) 11 | echo '-- Setting mysql group to use gid '$TARGET_GID 12 | groupmod -o -g $TARGET_GID mysql || true 13 | echo 14 | echo '* Starting Percona' 15 | chown -R mysql:root /var/run/mysqld/ 16 | /docker-entrypoint.sh mysqld --user=mysql --console 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/.stack.nginx.Dockerfile: -------------------------------------------------------------------------------- 1 | # Project nginx docker image with source code 2 | # -------------------------------- 3 | 4 | FROM nginx:1.7 5 | 6 | # Add source code to /src 7 | COPY . /app 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/.stack.php.Dockerfile: -------------------------------------------------------------------------------- 1 | # Project php docker image with source code 2 | # -------------------------------- 3 | 4 | FROM neam/dna-project-base-debian-php:1.0.0 5 | 6 | # Add source code to /src 7 | COPY . /app 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for local development 2 | version: '2' 3 | services: 4 | 5 | # The local mock version of the public haproxy router, responsible for serving the correct "web" service based on the VIRTUAL_HOST 6 | # locally we only have a single "web" service, nonetheless it is important to locally mimic the complete request chain 7 | router: 8 | image: dockercloud/haproxy:1.4.2 9 | links: 10 | - web 11 | ports: 12 | - "80:80" 13 | # Publish stats port 14 | - "1936" 15 | environment: 16 | TIMEOUT: connect 500, client 120000, server 120000 17 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 18 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 19 | # Necessary for auto-scaling using Docker-for-Mac 20 | volumes: 21 | - /var/run/docker.sock:/var/run/docker.sock 22 | 23 | # The nginx server for serving static files directly, cached contents via the memcached server and php files via the php service 24 | web: 25 | image: nginx:1.7 26 | links: 27 | - phphaproxy 28 | - phpfiles 29 | volumes: 30 | - ./stack:/stack:rw 31 | - .:/app:rw 32 | ports: 33 | - "80" 34 | environment: 35 | NGINX_ERROR_LOG_LEVEL: 'notice' 36 | VIRTUAL_HOST: '*.127.0.0.1.xip.io, 127.0.0.1, *._PROJECT_.build.neamlabs.com, *.ngrok.io' 37 | # The haproxy router is configured to respond to port 80 without ssl, thus we need to make sure that proxying to the web service's port 443 is not attempted 38 | # A separate haproxy and corresponding web service needs to be set up to respond to port 443 with ssl if required 39 | EXCLUDE_PORTS: 443 40 | working_dir: '/app' 41 | command: "/stack/nginx/run.sh" 42 | 43 | # HA Proxy for php service scaling 44 | phphaproxy: 45 | image: dockercloud/haproxy:1.6.7 46 | links: 47 | - phpha 48 | ports: 49 | - "9000" 50 | # Publish stats port 51 | - "1936" 52 | environment: 53 | MODE: tcp 54 | TCP_PORTS: 9000 55 | TIMEOUT: connect 500, client 120000, server 120000 56 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 57 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 58 | # Necessary for auto-scaling using Docker-for-Mac 59 | volumes: 60 | - /var/run/docker.sock:/var/run/docker.sock 61 | 62 | # The elastically scalable php service for interpreting php code without access to /files 63 | phpha: 64 | image: neam/dna-project-base-debian-php:1.0.0 65 | links: 66 | - mailcatcher 67 | - redisphpsessionhandler 68 | - localdb 69 | volumes: 70 | - ./stack:/stack:rw 71 | - .:/app:rw 72 | # Use to inspect the local tmp files directory if necessary 73 | # - .local-tmp-files:/local-tmp-files:rw 74 | ports: 75 | - "9000" 76 | - "9089" # Xdebug 77 | environment: 78 | TCP_PORTS: '9000' 79 | DISPLAY_PHP_ERRORS: 'off' 80 | LOAD_XDEBUG_EXTENSION: '0' 81 | XDEBUG_DEFAULT_ENABLE: 'off' 82 | RUNNING_LOCALLY: '1' 83 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 84 | PHP_PACKAGE_NAME_VERSION: '7.0' 85 | env_file: 86 | - .env 87 | working_dir: '/app' 88 | command: "/stack/php/run.sh" 89 | 90 | # The redis service used as the PHP session handler for all containers 91 | redisphpsessionhandler: 92 | image: redis 93 | ports: 94 | - "6379" 95 | 96 | # The single-node php service for interpreting php code with read-write access to user-generated files 97 | # (to support file uploads and other local file manipulations) 98 | phpfiles: 99 | image: neam/dna-project-base-debian-php:1.0.0 100 | links: 101 | - mailcatcher 102 | - redisphpsessionhandler 103 | - localdb 104 | volumes: 105 | - ./stack:/stack:rw 106 | - .:/app:rw 107 | - .files:/files:rw 108 | ports: 109 | - "9000" 110 | - "9089" # Xdebug 111 | environment: 112 | TCP_PORTS: '9000' 113 | DISPLAY_PHP_ERRORS: 'off' 114 | LOAD_XDEBUG_EXTENSION: '0' 115 | XDEBUG_DEFAULT_ENABLE: 'off' 116 | RUNNING_LOCALLY: '1' 117 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 118 | PHP_PACKAGE_NAME_VERSION: '7.0' 119 | env_file: 120 | - .env 121 | working_dir: '/app' 122 | command: "/stack/php/run.sh" 123 | 124 | # Local MySQL database server to mimic a cloud database 125 | localdb: 126 | image: mysql:5.7.11 127 | volumes: 128 | - sq-project-personal-unit-localdb-var-lib-mysql-persistent:/var/lib/mysql:rw 129 | - ./stack/localdb/:/stack/localdb:rw 130 | ports: 131 | - "13306:3306" 132 | environment: 133 | MYSQL_ROOT_PASSWORD: "local-mysql-pass" 134 | command: "/stack/localdb/run.sh" 135 | 136 | # Memcached server for serving cached contents via the nginx-memcache plugin 137 | #memcached: 138 | # image: memcached:1.4.22 139 | # ports: 140 | # - "11211" 141 | 142 | # Mailcatcher server for catching outgoing email when not in production 143 | mailcatcher: 144 | image: nisenabe/mailcatcher 145 | expose: 146 | - "25" 147 | ports: 148 | - "1080" 149 | 150 | # Containers to run tester commands locally - start a shell by running stack/tester-shell.sh 151 | tester-php7.0: 152 | image: neam/dna-project-base-debian-php:1.0.0 153 | links: 154 | - web 155 | - localdb 156 | volumes: 157 | - ./stack:/stack:rw 158 | - .:/app:rw 159 | - .:/personal-unit:rw 160 | - .files:/files:rw 161 | - ../.git:/.git 162 | - ~/.composer:/root/.composer 163 | - ~/.gitconfig:/root/.gitconfig 164 | - ~/.ssh:/root/.ssh:ro 165 | environment: 166 | DISPLAY_PHP_ERRORS: 'off' 167 | LOAD_XDEBUG_EXTENSION: '1' 168 | XDEBUG_DEFAULT_ENABLE: 'off' 169 | RUNNING_LOCALLY: '1' 170 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 171 | PHP_PACKAGE_NAME_VERSION: '7.0' 172 | working_dir: '/app' 173 | env_file: 174 | - .default-local-cli-data-profile 175 | command: "/stack/php/shell.sh /app/dna/tests" 176 | 177 | tester-php7.1: 178 | image: neam/dna-project-base-debian-php:1.0.0-php7.1 179 | links: 180 | - web 181 | - localdb 182 | volumes: 183 | - ./stack:/stack:rw 184 | - .:/app:rw 185 | - .:/personal-unit:rw 186 | - .files:/files:rw 187 | - ../.git:/.git 188 | - ~/.composer:/root/.composer 189 | - ~/.gitconfig:/root/.gitconfig 190 | - ~/.ssh:/root/.ssh:ro 191 | environment: 192 | DISPLAY_PHP_ERRORS: 'off' 193 | LOAD_XDEBUG_EXTENSION: '0' 194 | XDEBUG_DEFAULT_ENABLE: 'off' 195 | RUNNING_LOCALLY: '1' 196 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 197 | PHP_PACKAGE_NAME_VERSION: '7.1' 198 | working_dir: '/app' 199 | env_file: 200 | - .default-local-cli-data-profile 201 | command: "/stack/php/shell.sh /app/dna/tests" 202 | 203 | tester-php7.2: 204 | image: neam/dna-project-base-debian-php:1.0.0-php7.2 205 | links: 206 | - web 207 | - localdb 208 | volumes: 209 | - ./stack:/stack:rw 210 | - .:/app:rw 211 | - .:/personal-unit:rw 212 | - .files:/files:rw 213 | - ../.git:/.git 214 | - ~/.composer:/root/.composer 215 | - ~/.gitconfig:/root/.gitconfig 216 | - ~/.ssh:/root/.ssh:ro 217 | environment: 218 | DISPLAY_PHP_ERRORS: 'off' 219 | LOAD_XDEBUG_EXTENSION: '0' 220 | XDEBUG_DEFAULT_ENABLE: 'off' 221 | RUNNING_LOCALLY: '1' 222 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 223 | PHP_PACKAGE_NAME_VERSION: '7.2' 224 | working_dir: '/app' 225 | env_file: 226 | - .default-local-cli-data-profile 227 | command: "/stack/php/shell.sh /app/dna/tests" 228 | 229 | tester-hhvm: 230 | image: neam/dna-project-base-debian-php:1.0.0 231 | links: 232 | - web 233 | - localdb 234 | volumes: 235 | - ./stack:/stack:rw 236 | - .:/app:rw 237 | - .:/personal-unit:rw 238 | - .files:/files:rw 239 | - ../.git:/.git 240 | - ~/.composer:/root/.composer 241 | - ~/.gitconfig:/root/.gitconfig 242 | - ~/.ssh:/root/.ssh:ro 243 | environment: 244 | DISPLAY_PHP_ERRORS: 'off' 245 | LOAD_XDEBUG_EXTENSION: '1' 246 | XDEBUG_DEFAULT_ENABLE: 'off' 247 | RUNNING_LOCALLY: '1' 248 | HHVM: '1' # 1 = Use HHVM instead of the default PHP interpreter 249 | working_dir: '/app' 250 | env_file: 251 | - .default-local-cli-data-profile 252 | command: "/stack/php/shell.sh /app/dna/tests" 253 | 254 | # A container to run worker/administration commands locally - start a shell by running stack/shell.sh 255 | shell: 256 | image: neam/dna-project-base-debian-php:1.0.0 257 | links: 258 | - localdb 259 | volumes: 260 | - ./stack:/stack:rw 261 | - .:/app:rw 262 | - .files:/files:rw 263 | - ../.git:/.git 264 | - ~/.composer:/root/.composer 265 | - ~/.gitconfig:/root/.gitconfig 266 | - ~/.ssh:/root/.ssh:ro 267 | environment: 268 | DISPLAY_PHP_ERRORS: 'off' 269 | LOAD_XDEBUG_EXTENSION: '1' 270 | XDEBUG_DEFAULT_ENABLE: 'off' 271 | RUNNING_LOCALLY: '1' 272 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 273 | PHP_PACKAGE_NAME_VERSION: '7.0' 274 | working_dir: '/app' 275 | env_file: 276 | - .default-local-cli-data-profile 277 | command: "/stack/php/shell.sh" 278 | 279 | volumes: 280 | sq-project-personal-unit-localdb-var-lib-mysql-persistent: 281 | external: true 282 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/README.md: -------------------------------------------------------------------------------- 1 | Docker-based Stack - DNA Project Base (Based on Debian PHP/Nginx) 2 | =================================== 3 | 4 | ## Stack overview 5 | 6 | Type: LEMP 7 | 8 | * Linux (Debian 9.0 Stretch) 9 | * Nginx 1.7 10 | * MySQL 5.7.11 locally (to mimic the Amazon RDS instance in production) 11 | * PHP 7.0.27, 7.1.17 or HHVM 3.x.y 12 | 13 | ## Changelog 14 | 15 | This stack and/or underlying concepts are used in production by [Neam Labs](http://neamlabs.com) and are [constantly tweaked to be faster and more reliable](https://github.com/neam/docker-stack/blob/develop/CHANGELOG.md). 16 | 17 | ## Features 18 | 19 | * Follows Docker's one-process-per-container philosophy by having separate containers for Nginx and PHP-FPM 20 | * Uses a Debian-derived PHP image and the official Nginx Docker image 21 | * Includes boilerplate configuration with Docker-specific enhancements 22 | * Includes both a PHP "ha" service which is not supposed to use any data volumes and thus can be scaled elastically, as well as a PHP "files" container which uses a /files volume to stored user-uploaded files 23 | * The PHP "ha" service is fronted by a HAProxy service that distributes the load to the PHP "ha" service containers 24 | * The PHP services can use either PHP-FPM with Opcache (default) or HHVM 25 | * Includes a PHP cli / shell container to run worker/administration commands locally - start a shell by running stack/shell.sh 26 | * Includes the mailcatcher SMTP server for local development of mailing logic 27 | * Includes a local MySQL server to mimic Amazon RDS 28 | * Compatible with deployment routines explained in [https://github.com/neam/dna-project-base-cloud-deployment](https://github.com/neam/dna-project-base-cloud-deployment) 29 | 30 | ## Default configuration 31 | 32 | A frontend nginx location on / is configured to use the "ha" PHP service. A backend nginx location on /backend/ is configured to use the "files" PHP service. 33 | 34 | The frontend can be scaled horizontally and is thus served by different containers on each request, while the backend is always served by the same container. 35 | 36 | A Redis service is included in the docker stack and configured as the PHP session handler for all containers. 37 | 38 | ## Installation 39 | 40 | Clone docker-stack: 41 | 42 | git clone https://github.com/neam/docker-stack ~/.docker-stack -b develop 43 | 44 | If you already have docker-stack installed, you can update it by running: 45 | 46 | cd ~/.docker-stack 47 | git pull 48 | 49 | Enter your project directory (can be an empty directory in case you simply want to try out the stack): 50 | 51 | cd ~ 52 | mkdir myapp 53 | cd myapp 54 | 55 | Then run the following commands to copy the boilerplate stack files to your 12-factor app base dir. 56 | 57 | cp -v -r ~/.docker-stack/stacks/neam/debian-php-nginx/ . 58 | cp -v -r ~/.docker-stack/stacks/neam/debian-php-nginx.dna-project-base/ . 59 | 60 | ## Usage 61 | 62 | To try this stack out-of-the-box after installing it, you need a local `.env` where environment variables are specified which will be available to the PHP containers: 63 | 64 | echo 'FOO=bar' >> .env 65 | 66 | Then, fire up the stack locally: 67 | 68 | docker-compose up -d 69 | 70 | Visit the stack-hello pages by visiting the URL returned by: 71 | 72 | stack/url.sh web 80 - /stack-hello/ 73 | 74 | > Hint: On OSX, you can open the url directly from a terminal session: 75 | 76 | open $(stack/url.sh web 80 - /stack-hello/) 77 | 78 | To scale the PHP "ha" service: 79 | 80 | docker-compose scale phpha=3 81 | 82 | On OSX, you can open the phphaproxy's statistics page to verify that the scaling is effective: 83 | 84 | stack/phphaproxy-stats.sh 85 | 86 | ## Frontend and backend example 87 | 88 | Create the index php files expected by the default configuration: 89 | 90 | mkdir -p frontend/www 91 | mkdir -p backend/www 92 | echo ' frontend/www/index.php 93 | echo ' backend/www/index.php 94 | 95 | Visit the below returned urls in your browser (frontend and backend respectively): 96 | 97 | stack/url.sh 98 | stack/url.sh web 80 - /backend/ 99 | 100 | > Hint: On OSX, you can open the url directly from a terminal session: 101 | > 102 | > stack/open-browser.sh 103 | > stack/open-browser.sh /backend/ 104 | 105 | ## Deployment 106 | 107 | For thorough instructions and helpers scripts (needs "minimum-stability": "dev" in your composer.json): 108 | 109 | composer require neam/dna-project-base-cloud-deployment 110 | 111 | Then, follow instructions under `vendor/neam/dna-project-base-cloud-deployment/README.md` 112 | 113 | ## Local Extras 114 | 115 | The local stack include optional containers that emulate upstream services outside of your control. Simply comment them out if you do not need them. 116 | 117 | ### Explanation of the extra local containers 118 | 119 | * `localdb` - Runs a local MySQL server 120 | * `mailcatcher` - Runs a mailcatcher SMTP server 121 | 122 | ### Corresponding service in production 123 | 124 | * `localdb` - A cloud database service such as Amazon RDS, Rackspace CloudDB etc 125 | * `mailcatcher` - An SMTP service such as Gmail, Amazon Simple Mail Service, Foo etc 126 | 127 | ### Using localdb 128 | 129 | In order to connect to your local database from your work station, use the following credentials: 130 | 131 | User: admin 132 | Password: local-mysql-pass 133 | 134 | Connect to the host and port given by: 135 | 136 | stack/db-info.sh 137 | 138 | ## Using mailcatcher 139 | 140 | Configure your app to send emails using `mailcatcher` as the SMTP server against port 25. 141 | 142 | The emails will show up in the web frontend accessible on the url given by the following command: 143 | 144 | stack/url.sh mailcatcher 1080 145 | 146 | ## Customization 147 | 148 | ### Configuration 149 | 150 | Optionally, generate your project php/nginx base configuration based on composer.json metadata: [Follow these instructions](../../generators/server-config-generator/README.md) 151 | 152 | Customize your php/nginx configuration by changing the files in your project's `stack/nginx/` and `stack/php/` directories. 153 | 154 | To use PHP-FPM instead of HHVM, comment the "hhvm"-related lines almost at the bottom of your project's `stack/php/run.sh`, and uncomment the "php-fpm" line. 155 | 156 | Also, because HHVM seems to alter the SCRIPT_NAME and DOCUMENT_ROOT params from nginx, add the following to your index.php file: 157 | 158 | // HHVM SCRIPT_NAME difference vs php-fpm workaround 159 | if (defined('HHVM_VERSION')) { 160 | $_SERVER['DOCUMENT_ROOT'] = $_SERVER['NGINX_DOCUMENT_ROOT']; 161 | $_SERVER['SCRIPT_NAME'] = $_SERVER['NGINX_SCRIPT_NAME']; 162 | $_SERVER['PHP_SELF'] = $_SERVER['NGINX_SCRIPT_NAME']; 163 | } 164 | 165 | And make sure to keep the following in your nginx location blocks (see docker-stack/stacks/debian-php-nginx/stack/nginx/conf.d/app.conf): 166 | 167 | # for hhvm 168 | fastcgi_keep_conn on; 169 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 170 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 171 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/activate-nfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # use nfs locally on mac for performance 4 | if [ $(uname -s) = "Darwin" ]; then 5 | # make sure we use NFS for /Users mount 6 | echo '/Users:/Users' > stack/d4m-nfs/etc/d4m-nfs-mounts.txt 7 | # activate nfs 8 | stack/d4m-nfs/d4m-nfs.sh 9 | else 10 | echo "Not a mac, not activating NFS" 11 | fi 12 | 13 | exit 0 -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/localdb-shell.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | set -x 11 | 12 | # run actual command 13 | echo "Starting /bin/bash in a new tester container... " 14 | docker-compose -f docker-compose.yml run --rm localdb /stack/localdb/shell.sh 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/localdb/.db/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/localdb/manage-permissions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Script to workaround docker-machine/boot2docker OSX host volume issues: https://github.com/docker-library/mysql/issues/99 5 | 6 | echo '* Working around permission errors locally by making sure that "mysql" uses the same uid and gid as the host volume' 7 | TARGET_UID=$(stat -c "%u" /var/lib/mysql) 8 | echo '-- Setting mysql user to use uid '$TARGET_UID 9 | usermod -o -u $TARGET_UID mysql || true 10 | TARGET_GID=$(stat -c "%g" /var/lib/mysql) 11 | echo '-- Setting mysql group to use gid '$TARGET_GID 12 | groupmod -o -g $TARGET_GID mysql || true 13 | echo '-- Setting /var/run/mysqld to be owned by mysql:root' 14 | chown -R mysql:root /var/run/mysqld/ 15 | echo 16 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/localdb/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Manage permissions 5 | /stack/localdb/manage-permissions.sh 6 | 7 | # RDS defaults (https://gist.github.com/onyxraven/3834532) 8 | RDS_DEFAULTS="--tmp_table_size=16777216 --max_heap_table_size=16777216 --table_open_cache=400 --thread_cache_size=0 --innodb_flush_log_at_trx_commit=1 --max_allowed_packet=1048576" 9 | 10 | # Start server locally 11 | echo '* Starting MySQL' 12 | #/entrypoint.sh mysqld --user=mysql --console $RDS_DEFAULTS 13 | # no rds defaults for db imports 14 | /entrypoint.sh mysqld --user=mysql --console --sql_mode=NO_ENGINE_SUBSTITUTION 15 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/localdb/shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Manage permissions 5 | /stack/localdb/manage-permissions.sh 6 | 7 | # Start a shell 8 | bash 9 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # run actual command 11 | docker-compose -f docker-compose.yml run --rm logs -f $@ 12 | 13 | exit 0 14 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/conf.d/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neam/docker-stack/d21afd4638a1786aadf0e916a150abc72b234f06/stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/conf.d/.gitkeep -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | 2 | index index.php; 3 | 4 | server { 5 | server_name localhost; 6 | listen 80; 7 | 8 | #Specify a charset 9 | charset utf-8; 10 | 11 | # Framework-specific config 12 | root /app/frontend/www; 13 | 14 | # Attempt the uri, uri+/, then fall back to yii's index.php with args included 15 | location / { 16 | try_files $uri $uri/ /index.php?$args; 17 | } 18 | 19 | # Prevent access to yii protected directories 20 | location ~ ^/(protected|framework|themes/\w+/views) { 21 | deny all; 22 | } 23 | 24 | location ~ \.(hh|php) { 25 | include fastcgi_params; 26 | fastcgi_buffers 256 4k; 27 | fastcgi_param SCRIPT_FILENAME $request_filename; 28 | fastcgi_param HTTPS $proxied_https; 29 | 30 | # for hhvm 31 | fastcgi_keep_conn on; 32 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 33 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 34 | 35 | fastcgi_pass phpha; 36 | } 37 | 38 | include /app/stack/nginx/include/location-defaults.conf; 39 | 40 | location /backend/ { 41 | 42 | alias /app/backend/www/; 43 | 44 | # serve static files direct + allow friendly urls 45 | # Note: The seemingly weird syntax is due to a long-standing bug in nginx: https://trac.nginx.org/nginx/ticket/97 46 | try_files $uri $uri/ /backend//backend/index.php?$args; 47 | 48 | # Prevent access to yii protected directories 49 | location ~ ^/backend/(protected|framework|themes/\w+/views) { 50 | deny all; 51 | } 52 | 53 | location ~ /backend/.+\.(hh|php)$ { 54 | include fastcgi_params; 55 | fastcgi_buffers 256 4k; 56 | fastcgi_param SCRIPT_FILENAME $request_filename; 57 | fastcgi_param HTTPS $proxied_https; 58 | 59 | # for hhvm 60 | fastcgi_keep_conn on; 61 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 62 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 63 | 64 | fastcgi_pass phpfiles; 65 | } 66 | 67 | include /app/stack/nginx/include/location-defaults.conf; 68 | include /app/stack/nginx/include/backend-location-defaults.conf; 69 | 70 | } # / location 71 | 72 | } 73 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/include/backend-location-defaults.conf: -------------------------------------------------------------------------------- 1 | # allows file uploads up to 200 megabytes 2 | client_max_body_size 200M; 3 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/include/location-defaults.conf: -------------------------------------------------------------------------------- 1 | ## All files/directories that are protected and unaccessible from 2 | ## the web. 3 | location ~* ^.*(\.(?:git|svn|htaccess|pot?))$ { 4 | return 404; 5 | } 6 | 7 | ## Static files are served directly. 8 | #location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ { 9 | # expires max; 10 | # log_not_found off; 11 | # ## No need to bleed constant updates. Send the all shebang in one 12 | # ## fell swoop. 13 | # tcp_nodelay off; 14 | # ## Set the OS file cache. 15 | # #open_file_cache max=1000 inactive=120s; 16 | # #open_file_cache_valid 45s; 17 | # #open_file_cache_min_uses 2; 18 | # #open_file_cache_errors off; 19 | #} 20 | 21 | ## Don't use server listen port in redirects (since it will only make sense to users in case the listen port of nginx happened to be port 80) 22 | port_in_redirect off; 23 | 24 | ## Pseudo streaming for FLVs. 25 | ## http://wiki.nginx.org/HttpFlvStreamModule. 26 | # Note: This module is currently not available in appsdeck-buildpack-php, thus the following is commented out: 27 | #location ~* \.flv$ { 28 | # flv; 29 | #} 30 | 31 | ## Pseudo streaming of H264/AAC files. This requires an Nginx 32 | ## version greater or equal to 1.0.7 for the stable branch and 33 | ## greater or equal to 1.1.3 for the development branch. 34 | ## Cf. http://nginx.org/en/docs/http/ngx_http_mp4_module.html. 35 | # Note: This module is currently not available in appsdeck-buildpack-php, thus the following is commented out: 36 | #location ~* .*\.(?:m4a|mp4|mov)$ { 37 | # mp4; 38 | # mp4_buffer_size 1M; 39 | # mp4_max_buffer_size 5M; 40 | #} 41 | 42 | ## Keep a tab on the 'big' static files. 43 | #location ~* ^.+\.(?:ogg|pdf|pptx?)$ { 44 | # expires 30d; 45 | # ## No need to bleed constant updates. Send the all shebang in one 46 | # ## fell swoop. 47 | # tcp_nodelay off; 48 | #} 49 | 50 | # set fastcgi_read_timeout to the same as php's max_execution_time to avoid 504 Gateway timeout on slow php requests (default is 10s) 51 | fastcgi_send_timeout 300s; 52 | fastcgi_read_timeout 300s; 53 | fastcgi_connect_timeout 3s; 54 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/nginx/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is run within the nginx:1.7-based container on start 4 | 5 | # Fail on any error 6 | set -o errexit 7 | 8 | # Copy nginx configuration from app directory to nginx container 9 | 10 | # Remove existing config files 11 | if [ "$(ls /etc/nginx/conf.d/)" ]; then 12 | rm /etc/nginx/conf.d/*.conf 13 | fi 14 | 15 | # Copy custom project include files 16 | if [ "$(ls /stack/nginx/conf.d/)" ]; then 17 | cp -r /stack/nginx/conf.d/* /etc/nginx/conf.d/ 18 | fi 19 | cp /stack/nginx/nginx.conf /etc/nginx/nginx.conf 20 | cp -r /stack/nginx/include /etc/nginx/include 21 | 22 | # Example of using environment variable in configuration at runtime 23 | if [ ! -n "$NGINX_ERROR_LOG_LEVEL" ] ; then 24 | NGINX_ERROR_LOG_LEVEL="warn" 25 | fi 26 | sed -i "s|\${NGINX_ERROR_LOG_LEVEL}|${NGINX_ERROR_LOG_LEVEL}|" /etc/nginx/nginx.conf 27 | 28 | # Run nginx 29 | nginx -g 'daemon off;' 30 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/open-browser.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ "$DATA" == "" ] || [ "$DATA" == "%DATA%" ]; then 4 | echo "Using DATA=clean-db since no DATA env var was set. To set:" 5 | echo " export DATA=example" 6 | echo "Then run this script again" 7 | DATA=clean-db 8 | fi 9 | 10 | URL="$(stack/url.sh router 80 $DATA._PROJECT_.127.0.0.1.xip.io "$1")" 11 | 12 | echo "Opening URL:" 13 | echo $URL 14 | 15 | case $OSTYPE in 16 | darwin*) 17 | open $URL ;; 18 | linux-gnu) 19 | xdg-open $URL ;; 20 | *) 21 | 22 | esac 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.0.27, HHVM 3.x.y) built for PHP/Nginx DNA Project Base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/dna-project-base-debian-php:1.0.0 . 4 | # docker push neam/dna-project-base-debian-php:1.0.0 5 | 6 | FROM neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 7 | 8 | MAINTAINER Fredrik Wollsén 9 | 10 | # Add stretch backports (to be able to get some more updated versions of software packages) 11 | RUN echo 'deb http://http.debian.net/debian stretch-backports main contrib non-free' > /etc/apt/sources.list.d/stretch-backports.list 12 | 13 | # Apt source for: Database clients 14 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 15 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 16 | rm mysql-apt-config_0.8.6-1_all.deb 17 | 18 | # Apt source for: Google Cloud SDK 19 | RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ 20 | echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ 21 | curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 22 | 23 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 24 | RUN apt-get update && \ 25 | apt-get upgrade -y -q # 2018-05-09 19:40 26 | 27 | # Enable editors and general tools for administration processes 28 | ENV TERM xterm 29 | RUN apt-get install -y -q \ 30 | curl \ 31 | wget \ 32 | gnupg \ 33 | htop \ 34 | less \ 35 | jq \ 36 | nano \ 37 | man-db \ 38 | lsb-release \ 39 | sed \ 40 | telnet \ 41 | net-tools \ 42 | vim 43 | 44 | # Install Node.js (incl. npm for installation of dependencies during build) (Note: runs apt-get update) 45 | RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \ 46 | echo "nodejs \n $(apt-cache show nodejs | grep -i version)" && \ 47 | apt-get install -y nodejs=8.11.* 48 | 49 | # For erb templates 50 | RUN apt-get install -y -q \ 51 | ruby-full 52 | 53 | # Install s3cmd 54 | RUN apt-get install -y -q s3cmd=1.6.1* || (echo "s3cmd \n $(apt-cache show s3cmd | grep -i version)" && exit 1) 55 | 56 | # Install pipe viewer (pv) to monitor progress of commands that pipes large files 57 | RUN apt-get install -y -q pv 58 | 59 | # Install tmate for on-demand ssh access directly into containers 60 | RUN apt-get install -y -q tmate 61 | 62 | # Build essential is necessary to compile some binary dependencies (incl npm dependencies) 63 | RUN apt-get install build-essential -y -q 64 | 65 | # Install exiftool 66 | #RUN apt-get install -t stretch-backports -y -q \ 67 | # libimage-exiftool-perl=10.79.0* || (echo "exiftool \n $(apt-cache show libimage-exiftool-perl | grep -i version)" && exit 1) 68 | RUN wget https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.79.tar.gz && \ 69 | tar -xvf Image-ExifTool-10.79.tar.gz && \ 70 | cd Image-ExifTool-10.79 && ls -l && \ 71 | perl Makefile.PL && \ 72 | make test && \ 73 | make install && \ 74 | cd - && \ 75 | rm Image-ExifTool-10.79.tar.gz 76 | 77 | # Version control systems 78 | RUN apt-get install -y -q \ 79 | git-flow \ 80 | git-svn \ 81 | mercurial \ 82 | subversion 83 | 84 | # Database clients 85 | RUN apt-get install -y -q \ 86 | mysql-client 87 | 88 | # Google Cloud SDK 89 | RUN apt-get install -y -q \ 90 | google-cloud-sdk && \ 91 | gcloud config set pass_credentials_to_gsutil false 92 | 93 | # Clean apt caches 94 | RUN apt-get clean && \ 95 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 96 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php/php7.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.1.17, HHVM 3.x.y) built for PHP/Nginx DNA Project Base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/dna-project-base-debian-php:1.0.0-php7 . 4 | # docker push neam/dna-project-base-debian-php:1.0.0-php7 5 | 6 | FROM neam/debian-php:fpm-7.1.17-hhvm-3.x.y-for-debian-php-nginx-stack 7 | 8 | MAINTAINER Fredrik Wollsén 9 | 10 | # Add stretch backports (to be able to get some more updated versions of software packages) 11 | RUN echo 'deb http://http.debian.net/debian stretch-backports main contrib non-free' > /etc/apt/sources.list.d/stretch-backports.list 12 | 13 | # Apt source for: Database clients 14 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 15 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 16 | rm mysql-apt-config_0.8.6-1_all.deb 17 | 18 | # Apt source for: Google Cloud SDK 19 | RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ 20 | echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ 21 | curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 22 | 23 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 24 | RUN apt-get update && \ 25 | apt-get upgrade -y -q # 2018-05-09 19:40 26 | 27 | # Enable editors and general tools for administration processes 28 | ENV TERM xterm 29 | RUN apt-get install -y -q \ 30 | curl \ 31 | wget \ 32 | gnupg \ 33 | htop \ 34 | less \ 35 | jq \ 36 | nano \ 37 | man-db \ 38 | lsb-release \ 39 | sed \ 40 | telnet \ 41 | net-tools \ 42 | vim 43 | 44 | # Install Node.js (incl. npm for installation of dependencies during build) (Note: runs apt-get update) 45 | RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \ 46 | echo "nodejs \n $(apt-cache show nodejs | grep -i version)" && \ 47 | apt-get install -y nodejs=8.11.* 48 | 49 | # For erb templates 50 | RUN apt-get install -y -q \ 51 | ruby-full 52 | 53 | # Install s3cmd 54 | RUN apt-get install -y -q s3cmd=1.6.1* || (echo "s3cmd \n $(apt-cache show s3cmd | grep -i version)" && exit 1) 55 | 56 | # Install pipe viewer (pv) to monitor progress of commands that pipes large files 57 | RUN apt-get install -y -q pv 58 | 59 | # Install tmate for on-demand ssh access directly into containers 60 | RUN apt-get install -y -q tmate 61 | 62 | # Build essential is necessary to compile some binary dependencies (incl npm dependencies) 63 | RUN apt-get install build-essential -y -q 64 | 65 | # Install exiftool 66 | #RUN apt-get install -t stretch-backports -y -q \ 67 | # libimage-exiftool-perl=10.79.0* || (echo "exiftool \n $(apt-cache show libimage-exiftool-perl | grep -i version)" && exit 1) 68 | RUN wget https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.79.tar.gz && \ 69 | tar -xvf Image-ExifTool-10.79.tar.gz && \ 70 | cd Image-ExifTool-10.79 && ls -l && \ 71 | perl Makefile.PL && \ 72 | make test && \ 73 | make install && \ 74 | cd - && \ 75 | rm Image-ExifTool-10.79.tar.gz 76 | 77 | # Version control systems 78 | RUN apt-get install -y -q \ 79 | git-flow \ 80 | git-svn \ 81 | mercurial \ 82 | subversion 83 | 84 | # Database clients 85 | RUN apt-get install -y -q \ 86 | mysql-client 87 | 88 | # Google Cloud SDK 89 | RUN apt-get install -y -q \ 90 | google-cloud-sdk && \ 91 | gcloud config set pass_credentials_to_gsutil false 92 | 93 | # Clean apt caches 94 | RUN apt-get clean && \ 95 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 96 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/php/images/dna-project-base-debian-php/php7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.2.5, HHVM 3.x.y) built for PHP/Nginx DNA Project Base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/dna-project-base-debian-php:1.0.0-php7 . 4 | # docker push neam/dna-project-base-debian-php:1.0.0-php7 5 | 6 | FROM neam/debian-php:fpm-7.2.5-hhvm-3.x.y-for-debian-php-nginx-stack 7 | 8 | MAINTAINER Fredrik Wollsén 9 | 10 | # Add stretch backports (to be able to get some more updated versions of software packages) 11 | RUN echo 'deb http://http.debian.net/debian stretch-backports main contrib non-free' > /etc/apt/sources.list.d/stretch-backports.list 12 | 13 | # Apt source for: Database clients 14 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 15 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 16 | rm mysql-apt-config_0.8.6-1_all.deb 17 | 18 | # Apt source for: Google Cloud SDK 19 | RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \ 20 | echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ 21 | curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 22 | 23 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 24 | RUN apt-get update && \ 25 | apt-get upgrade -y -q # 2018-05-09 19:40 26 | 27 | # Enable editors and general tools for administration processes 28 | ENV TERM xterm 29 | RUN apt-get install -y -q \ 30 | curl \ 31 | wget \ 32 | gnupg \ 33 | htop \ 34 | less \ 35 | jq \ 36 | nano \ 37 | man-db \ 38 | lsb-release \ 39 | sed \ 40 | telnet \ 41 | net-tools \ 42 | vim 43 | 44 | # Install Node.js (incl. npm for installation of dependencies during build) (Note: runs apt-get update) 45 | RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \ 46 | echo "nodejs \n $(apt-cache show nodejs | grep -i version)" && \ 47 | apt-get install -y nodejs=8.11.* 48 | 49 | # For erb templates 50 | RUN apt-get install -y -q \ 51 | ruby-full 52 | 53 | # Install s3cmd 54 | RUN apt-get install -y -q s3cmd=1.6.1* || (echo "s3cmd \n $(apt-cache show s3cmd | grep -i version)" && exit 1) 55 | 56 | # Install pipe viewer (pv) to monitor progress of commands that pipes large files 57 | RUN apt-get install -y -q pv 58 | 59 | # Install tmate for on-demand ssh access directly into containers 60 | RUN apt-get install -y -q tmate 61 | 62 | # Build essential is necessary to compile some binary dependencies (incl npm dependencies) 63 | RUN apt-get install build-essential -y -q 64 | 65 | # Install exiftool 66 | #RUN apt-get install -t stretch-backports -y -q \ 67 | # libimage-exiftool-perl=10.79.0* || (echo "exiftool \n $(apt-cache show libimage-exiftool-perl | grep -i version)" && exit 1) 68 | RUN wget https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.79.tar.gz && \ 69 | tar -xvf Image-ExifTool-10.79.tar.gz && \ 70 | cd Image-ExifTool-10.79 && ls -l && \ 71 | perl Makefile.PL && \ 72 | make test && \ 73 | make install && \ 74 | cd - && \ 75 | rm Image-ExifTool-10.79.tar.gz 76 | 77 | # Version control systems 78 | RUN apt-get install -y -q \ 79 | git-flow \ 80 | git-svn \ 81 | mercurial \ 82 | subversion 83 | 84 | # Database clients 85 | RUN apt-get install -y -q \ 86 | mysql-client 87 | 88 | # Google Cloud SDK 89 | RUN apt-get install -y -q \ 90 | google-cloud-sdk && \ 91 | gcloud config set pass_credentials_to_gsutil false 92 | 93 | # Clean apt caches 94 | RUN apt-get clean && \ 95 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 96 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/phphaproxy-stats.sh: -------------------------------------------------------------------------------- 1 | open $(stack/url.sh phphaproxy 1936 stats:n3v3rg0nnAg1v3y0uup@127.0.0.1) 2 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/recreate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # run actual command 11 | stack/stop.sh 12 | docker-compose rm -f 13 | stack/start.sh $@ 14 | 15 | exit 0 16 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # run actual command 11 | stack/stop.sh 12 | stack/start.sh 13 | 14 | exit 0 15 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/router-stats.sh: -------------------------------------------------------------------------------- 1 | open $(stack/url.sh router 1936 stats:n3v3rg0nnAg1v3y0uup@127.0.0.1) 2 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # builds production source-code such as dist versions of webapps 4 | 5 | # fail on any error 6 | set -o errexit 7 | 8 | # example 9 | cd ui/webapps/yeoman-app-1 10 | ./full-build.sh 11 | cd - 12 | 13 | cd ui/webapps/yeoman-app-2 14 | ./full-build.sh 15 | cd - 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/git-pull-recursive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | git pull 7 | git submodule init 8 | git submodule update --recursive 9 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/install-core-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # show commands 4 | set -x 5 | 6 | # fail on any error 7 | set -o errexit 8 | 9 | if [ "$PREFER" == "" ]; then 10 | PREFER=source 11 | fi 12 | 13 | composer install --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 14 | 15 | cd dna/ 16 | composer install --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 17 | cd - 18 | 19 | cd external-apis/rest-api 20 | composer install --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 21 | cd - 22 | 23 | cd external-apis/rest-api-dna 24 | composer install --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 25 | cd - 26 | 27 | cd tools/code-generator 28 | composer install --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 29 | cd - 30 | 31 | exit 0 32 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/install-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # show commands 4 | set -x 5 | 6 | # fail on any error 7 | set -o errexit 8 | 9 | export PREFER=$PREFER 10 | 11 | if [ -d /root/.docker-host-ssh ]; then 12 | echo '* Working around permission errors locally by copying .ssh config temporarily instead of using host-volume-mounted ditos' 13 | cp -r /root/.docker-host-ssh /root/.ssh 14 | fi 15 | 16 | script_path=`dirname $0` 17 | 18 | cd $script_path/../.. 19 | export project_abspath=$(pwd) 20 | 21 | # make sure that the shorthand "composer" is available and refers to using our shipped composer.phar (for the sake of consistency) 22 | function composer() { 23 | php $project_abspath/composer.phar $@ 24 | } 25 | export -f composer 26 | 27 | $script_path/install-core-deps.sh 28 | $script_path/install-local-deps.sh 29 | 30 | exit 0 31 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/install-local-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # show commands 4 | set -x 5 | 6 | # fail on any error 7 | set -o errexit 8 | 9 | if [ "$PREFER" == "" ]; then 10 | PREFER=source 11 | fi 12 | 13 | # install local deps if available 14 | # ... 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/reset-vendor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | confirm () { 4 | # call with a prompt string or use a default 5 | read -r -p "${1:-Are you sure? [y/N]} " response 6 | case $response in 7 | [yY][eE][sS]|[yY]) 8 | true 9 | ;; 10 | *) 11 | false 12 | ;; 13 | esac 14 | } 15 | 16 | # When running using docker-compose, the output from "read" will be hidden (bug?) so we echo the question instead 17 | echo "This will remove all vendor directories in $(pwd) and two sub-directories below, do you want to continue? [y/N]" 18 | confirm "" || exit 1 19 | 20 | # show commands 21 | set -x 22 | 23 | # fail on any error 24 | set -o errexit 25 | 26 | rm -rf vendor/ 27 | rm -rf */vendor/ 28 | rm -rf */*/vendor/ 29 | PREFER=dist stack/src/install-deps.sh 30 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/update-autoload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # show commands 4 | set -x 5 | 6 | # fail on any error 7 | set -o errexit 8 | 9 | # make sure that the shorthand "composer" is available and refers to using our shipped composer.phar (for the sake of consistency) 10 | script_path=`dirname $0` 11 | cd $script_path/../.. 12 | export project_abspath=$(pwd) 13 | function composer() { 14 | php $project_abspath/composer.phar $@ 15 | } 16 | export -f composer 17 | 18 | if [ "$PREFER" == "" ]; then 19 | PREFER=source 20 | fi 21 | 22 | composer dump-autoload 23 | 24 | cd dna/ 25 | composer dump-autoload 26 | cd - 27 | 28 | cd external-apis/rest-api 29 | composer dump-autoload 30 | cd - 31 | 32 | cd external-apis/rest-api-dna 33 | composer dump-autoload 34 | cd - 35 | 36 | cd tools/code-generator 37 | composer dump-autoload 38 | cd - 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/src/update-core-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # show commands 4 | set -x 5 | 6 | # fail on any error 7 | set -o errexit 8 | 9 | # make sure that the shorthand "composer" is available and refers to using our shipped composer.phar (for the sake of consistency) 10 | script_path=`dirname $0` 11 | cd $script_path/../.. 12 | export project_abspath=$(pwd) 13 | function composer() { 14 | php $project_abspath/composer.phar $@ 15 | } 16 | export -f composer 17 | 18 | if [ "$PREFER" == "" ]; then 19 | PREFER=source 20 | fi 21 | 22 | composer -vv update --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 23 | 24 | cd dna/ 25 | composer -vv update --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 26 | cd - 27 | 28 | cd external-apis/rest-api 29 | composer -vv update --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 30 | cd - 31 | 32 | cd tools/code-generator 33 | composer -vv update --prefer-$PREFER --optimize-autoloader --ignore-platform-reqs 34 | cd - 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # debug 4 | #set -x 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # make sure no other stack's containers are using the ports that our stack uses 11 | CURRENT_DIRECTORY="$(basename $(pwd))" 12 | DOCKERSTACKREF=${CURRENT_DIRECTORY//-/} 13 | docker ps | grep -v ${DOCKERSTACKREF}_ | grep '0.0.0.0:80->' | awk '{ print $1 }' | xargs docker kill 14 | docker ps | grep -v ${DOCKERSTACKREF}_ | grep '0.0.0.0:33306->' | awk '{ print $1 }' | xargs docker kill 15 | 16 | # fail on any error 17 | set -o errexit 18 | 19 | # start stack 20 | docker volume create --name=sq-project-personal-unit-localdb-var-lib-mysql-persistent 21 | 22 | # run actual command 23 | docker-compose -f docker-compose.yml up -d 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # run actual command 11 | docker-compose -f docker-compose.yml stop 12 | 13 | exit 0 14 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx.dna-project-base/stack/tester-shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | set -x 11 | 12 | if [ "$1" == "" ]; then 13 | FLAVOR="php7.0" 14 | else 15 | FLAVOR=$1 16 | fi 17 | 18 | # run actual command 19 | echo "Starting /bin/bash in a new tester container... " 20 | docker-compose -f docker-compose.yml run --rm tester-$FLAVOR 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/.stack.nginx.Dockerfile: -------------------------------------------------------------------------------- 1 | # Project nginx docker image with source code 2 | # -------------------------------- 3 | 4 | FROM nginx:1.7 5 | 6 | # Add source code to /src 7 | COPY . /app 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/.stack.php.Dockerfile: -------------------------------------------------------------------------------- 1 | # Project php docker image with source code 2 | # -------------------------------- 3 | 4 | FROM neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 5 | 6 | # Add source code to /src 7 | COPY . /app 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for local development 2 | version: '2' 3 | services: 4 | 5 | # The nginx server for serving static files directly, cached contents via the memcached server and php files via the php service 6 | web: 7 | image: nginx:1.7 8 | links: 9 | - phphaproxy 10 | - phpfiles 11 | volumes: 12 | - .:/app:rw 13 | ports: 14 | - "80" 15 | environment: 16 | NGINX_ERROR_LOG_LEVEL: 'notice' 17 | working_dir: '/app' 18 | command: "/app/stack/nginx/run.sh" 19 | 20 | # HA Proxy for php service scaling 21 | phphaproxy: 22 | image: dockercloud/haproxy:1.5.1 23 | links: 24 | - phpha 25 | ports: 26 | - "9000" 27 | # Publish stats port 28 | - "1936" 29 | environment: 30 | MODE: tcp 31 | TIMEOUT: connect 500, client 120000, server 120000 32 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 33 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 34 | # Necessary for auto-scaling using Docker-for-Mac 35 | volumes: 36 | - /var/run/docker.sock:/var/run/docker.sock 37 | 38 | # The elastically scalable php service for interpreting php code without access to /files 39 | phpha: 40 | image: neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 41 | links: 42 | - mailcatcher 43 | - redisphpsessionhandler 44 | volumes: 45 | - .:/app:rw 46 | ports: 47 | - "9000" 48 | - "9089" # Xdebug 49 | environment: 50 | TCP_PORTS: '9000' 51 | DISPLAY_PHP_ERRORS: 'on' 52 | LOAD_XDEBUG_EXTENSION: '1' 53 | XDEBUG_DEFAULT_ENABLE: 'off' 54 | RUNNING_LOCALLY: '1' 55 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 56 | PHP_PACKAGE_NAME_VERSION: '7.0' 57 | env_file: 58 | - .env 59 | working_dir: '/app' 60 | command: "/app/stack/php/run.sh" 61 | 62 | # The redis service used as the PHP session handler for all containers 63 | redisphpsessionhandler: 64 | image: redis 65 | ports: 66 | - "6379" 67 | 68 | # The single-node php service for interpreting php code with read-write access to user-generated files 69 | # (to support file uploads and other local file manipulations) 70 | phpfiles: 71 | image: neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 72 | links: 73 | - mailcatcher 74 | - redisphpsessionhandler 75 | volumes: 76 | - .:/app:rw 77 | - .files:/files:rw 78 | ports: 79 | - "9000" 80 | - "9089" # Xdebug 81 | environment: 82 | TCP_PORTS: '9000' 83 | DISPLAY_PHP_ERRORS: 'on' 84 | LOAD_XDEBUG_EXTENSION: '0' 85 | XDEBUG_DEFAULT_ENABLE: 'off' 86 | RUNNING_LOCALLY: '1' 87 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 88 | PHP_PACKAGE_NAME_VERSION: '7.0' 89 | env_file: 90 | - .env 91 | working_dir: '/app' 92 | command: "/app/stack/php/run.sh" 93 | 94 | # Mailcatcher server for catching outgoing email when not in production 95 | mailcatcher: 96 | image: nisenabe/mailcatcher 97 | expose: 98 | - "25" 99 | ports: 100 | - "1080" 101 | 102 | # A container to run worker/administration commands locally - start a shell by running stack/shell.sh 103 | shell: 104 | image: neam/dna-project-base-debian-php:1.0.0 105 | volumes: 106 | - .:/app:rw 107 | - .files:/files:rw 108 | - ../.git:/.git 109 | - ~/.composer:/root/.composer 110 | - ~/.gitconfig:/root/.gitconfig 111 | - ~/.ssh:/root/.ssh:ro 112 | environment: 113 | DISPLAY_PHP_ERRORS: 'off' 114 | LOAD_XDEBUG_EXTENSION: '1' 115 | XDEBUG_DEFAULT_ENABLE: 'off' 116 | RUNNING_LOCALLY: '1' 117 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 118 | PHP_PACKAGE_NAME_VERSION: '7.0' 119 | working_dir: '/app' 120 | command: "/app/stack/php/shell.sh" 121 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/frontend/www/stack-hello/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/frontend/www/stack-hello/phpinfo.php: -------------------------------------------------------------------------------- 1 | > .env 62 | 63 | Then, fire up the stack locally: 64 | 65 | docker-compose up -d 66 | 67 | Visit the stack-hello pages by visiting the URL returned by: 68 | 69 | stack/url.sh web 80 - /stack-hello/ 70 | 71 | > Hint: On OSX, you can open the url directly from a terminal session: 72 | 73 | open $(stack/url.sh web 80 - /stack-hello/) 74 | 75 | To scale the PHP "ha" service: 76 | 77 | docker-compose scale phpha=3 78 | 79 | On OSX, you can open the phphaproxy's statistics page to verify that the scaling is effective: 80 | 81 | stack/phphaproxy-stats.sh 82 | 83 | ## Frontend and backend example 84 | 85 | Create the index php files expected by the default configuration: 86 | 87 | mkdir -p frontend/www 88 | mkdir -p backend/www 89 | echo ' frontend/www/index.php 90 | echo ' backend/www/index.php 91 | 92 | Visit the below returned urls in your browser (frontend and backend respectively): 93 | 94 | stack/url.sh 95 | stack/url.sh web 80 - /backend/ 96 | 97 | > Hint: On OSX, you can open the url directly from a terminal session: 98 | 99 | open $(stack/url.sh web) 100 | open $(stack/url.sh web 80 - /backend/) 101 | 102 | ## Local Extras 103 | 104 | The local stack include optional containers that emulate upstream services outside of your control. Simply comment them out if you do not need them. 105 | 106 | ### Explanation of the extra local containers 107 | 108 | * `mailcatcher` - Runs a mailcatcher SMTP server 109 | 110 | ### Corresponding service in production 111 | 112 | * `mailcatcher` - An SMTP service such as Gmail, Amazon Simple Mail Service, Foo etc 113 | 114 | ## Using mailcatcher 115 | 116 | Configure your app to send emails using `mailcatcher` as the SMTP server against port 25. 117 | 118 | The emails will show up in the web frontend accessible on the url given by the following command: 119 | 120 | stack/url.sh mailcatcher 1080 121 | 122 | ## Customization 123 | 124 | ### Configuration 125 | 126 | Optionally, generate your project php/nginx base configuration based on composer.json metadata: [Follow these instructions](../../generators/server-config-generator/README.md) 127 | 128 | Customize your php/nginx configuration by changing the files in your project's `stack/nginx/` and `stack/php/` directories. 129 | 130 | To use PHP-FPM instead of HHVM, comment the "hhvm"-related lines almost at the bottom of your project's `stack/php/run.sh`, and uncomment the "php-fpm" line. 131 | 132 | Also, because HHVM seems to alter the SCRIPT_NAME and DOCUMENT_ROOT params from nginx, add the following to your index.php file: 133 | 134 | // HHVM SCRIPT_NAME difference vs php-fpm workaround 135 | if (defined('HHVM_VERSION')) { 136 | $_SERVER['DOCUMENT_ROOT'] = $_SERVER['NGINX_DOCUMENT_ROOT']; 137 | $_SERVER['SCRIPT_NAME'] = $_SERVER['NGINX_SCRIPT_NAME']; 138 | $_SERVER['PHP_SELF'] = $_SERVER['NGINX_SCRIPT_NAME']; 139 | } 140 | 141 | And make sure to keep the following in your nginx location blocks (see docker-stack/stacks/debian-php-nginx/stack/nginx/conf.d/app.conf): 142 | 143 | # for hhvm 144 | fastcgi_keep_conn on; 145 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 146 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 147 | 148 | ### Advanced 149 | 150 | Compare this stack to the stack found at `../debian-php-nginx.dna-project-base` for an example of how to customize this stack for a specific project set-up 151 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/db-info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$DOCKERSTACK_DEBUG" == "1" ]; then 4 | set -x; 5 | fi 6 | 7 | DRIVER=$1 8 | SERVICE_NAME=$2 9 | PORT=$3 10 | URL_PATH="${@:4}" 11 | 12 | if [ "$DRIVER" == "" ]; then 13 | DRIVER=mysql 14 | fi 15 | 16 | if [ "$SERVICE_NAME" == "" ]; then 17 | SERVICE_NAME=localdb 18 | fi 19 | 20 | if [ "$PORT" == "" ]; then 21 | PORT=3306 22 | fi 23 | 24 | export DOCKER_HOST_IP=$(echo $DOCKER_HOST | sed 's/tcp:\/\///' | sed 's/:[0-9.]*//'); 25 | export DB_PORT=$(docker-compose port $SERVICE_NAME $PORT | sed 's/[0-9.]*://'); 26 | if [ "DB_PORT" == "" ]; then 27 | echo "Could not find the corresponding DB_PORT" 28 | exit 1 29 | fi 30 | export URL="$DRIVER://$DOCKER_HOST_IP:$DB_PORT"; 31 | URL=$URL"$URL_PATH"; 32 | echo $URL; 33 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.docker-cloud.newrelic-agent.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for docker-cloud node newrelic agent 2 | 3 | newrelic-agent: 4 | image: 'tutum/newrelic-agent:latest' 5 | deployment_strategy: every_node 6 | environment: 7 | - HOSTNAME=$DOCKERCLOUD_NODE_HOSTNAME 8 | - 'NEW_RELIC_LICENSE_KEY=1234567890afaefaefaefaef1234567890afaefaefaefaef' 9 | net: host 10 | pid: host 11 | privileged: true 12 | restart: always 13 | volumes: 14 | - '/var/run/docker.sock:/var/run/docker.sock' 15 | - '/dev:/dev' 16 | - '/sys:/sys' 17 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.docker-cloud.router.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for docker-cloud deployment router (to run on publicly facing instances on port 80/443 where DNS records are pointed at) 2 | # This service has a single purpose: Mapping a virtual host request to corresponding services deployed in an elastic instance cluster. 3 | # Getting started: 4 | # 1. Launch two separate instances and make sure they have stable IP addresses (in AWS, use elastic ips) 5 | # 2. Add the instances as docker-cloud using the Bring-Your-Own-Node method (https://support.tutum.co/support/solutions/articles/5000513678-bring-your-own-node) 6 | # 3. Tag one of them "public-dev" and the other "public-prod" 7 | # 4. Launch one router-stack/service on each, resulting in the stacks/services routerprod and routerdev. 8 | # Production DNS entries are then mapped to the instance where routerprod is running, and development entries to the other one. 9 | 10 | %DEPLOY_STABILITY_TAG%-router: 11 | image: dockercloud/haproxy:1.4.2 12 | links: 13 | - %STACK_WEB_SERVICE_NAME_1% 14 | - %STACK_WEB_SERVICE_NAME_2% 15 | - %STACK_WEB_SERVICE_NAME_3% 16 | - %STACK_WEB_SERVICE_NAME_etc% 17 | ports: 18 | - "80:80" 19 | - "443:443" 20 | - "1936:1936" 21 | environment: 22 | # Clarify the timeout setting, making it easy to adjust 23 | TIMEOUT: connect 5000, client 120000, server 120000 24 | # Set 100k instead of default 4096 since we have experienced 7-20k simultaneous connections during high load (and even a t2.small instance handles way more than 4096 simultaneous connections) 25 | MAXCONN: 100000 26 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 27 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 28 | # Set to papertrailapp destination (or logstash/other service) 29 | RSYSLOG_DESTINATION: logs2.papertrailapp.com:55555 30 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node 31 | tags: 32 | - %DEPLOY_STABILITY_TAG%-router 33 | # Auto-restart in case container is stopped unexpectedly 34 | restart: always 35 | # Do not update the service when a new version is pushed to the registry (since we want finer control of when new configuration is applied) 36 | autoredeploy: false 37 | # Container distribution among nodes (so that we easily can add more public nodes elastically) 38 | deployment_strategy: every_node 39 | # Enable full Tutum API access so that the container can reconfigure itself 40 | roles: 41 | - global 42 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.docker-cloud.syslogger-papertrail.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for docker-cloud node syslogger 2 | 3 | syslogger: 4 | image: 'gliderlabs/logspout:v3' 5 | command: 'syslog://logs2.papertrailapp.com:55555' 6 | deployment_strategy: every_node 7 | environment: 8 | - HOSTNAME=$DOCKERCLOUD_NODE_HOSTNAME 9 | restart: always 10 | volumes: 11 | - '/var/run/docker.sock:/tmp/docker.sock' 12 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.docker-cloud.team-node-ssh-access.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for docker-cloud node ssh access (https://tutum.freshdesk.com/support/solutions/articles/5000553071-sshing-into-a-tutum-node) 2 | # First time deployment: 3 | # mkdir -p deployments/teamnodesshaccess/ 4 | # docker-cloud stack create --name=teamnodesshaccess -f stack/docker-compose-production.docker-cloud-ssh-node-access.yml | tee deployments/teamnodesshaccess/.docker-cloud-stack-id 5 | # docker-cloud stack start $(cat deployments/teamnodesshaccess/.docker-cloud-stack-id) 6 | # To update the stack, after a new key has been added or changed: 7 | # docker-cloud stack update -f stack/docker-compose-production.docker-cloud-ssh-node-access.yml $(cat deployments/teamnodesshaccess/.docker-cloud-stack-id) 8 | # docker-cloud stack redeploy $(cat deployments/teamnodesshaccess/.docker-cloud-stack-id) 9 | 10 | team-node-ssh-access-johndoe: 11 | image: borja/authkey 12 | environment: 13 | PUB_KEY: ssh-rsa 1234567890aefaefaefaefaefaefaefaefaefaef1234567890aefaefaefaefaefaefaefaefaefaef1234567890aefaefaefaefaefaefaefaefaefaef 14 | volumes: 15 | - /root/.ssh:/.ssh 16 | deployment_strategy: every_node 17 | autodestroy: always 18 | 19 | team-node-ssh-access-build_PROJECT_com: 20 | image: borja/authkey 21 | environment: 22 | PUB_KEY: ssh-rsa faefaefaefaefaef1234567890aefaefaefaefaefaefaefaefaefaef1234567890aefaefaefaefaefaefaefaefaefaef1234567890aefaefaefaefae 23 | volumes: 24 | - /root/.ssh:/.ssh 25 | deployment_strategy: every_node 26 | autodestroy: always 27 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.docker-cloud.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for docker-cloud deployment 2 | 3 | # The nginx server for serving static files directly, cached contents via the memcached server and php files via the php service 4 | %VIRTUAL_HOST_BASED_WEB_SERVICE_NAME%: # A unique service name makes it easier to identify in docker-cloud ui and api 5 | image: %DOCKERCLOUD_USER%/%REPO%-nginx:git-commit-%COMMITSHA% 6 | links: 7 | - phphaproxy 8 | - phpfiles 9 | ports: 10 | - "80" 11 | environment: 12 | NGINX_ERROR_LOG_LEVEL: 'notice' 13 | VIRTUAL_HOST: '%VIRTUAL_HOST%' 14 | # The haproxy router is configured to respond to port 80 without ssl, thus we need to make sure that proxying to the web service's port 443 is not attempted 15 | # A separate haproxy and corresponding web service needs to be set up to respond to port 443 with ssl if required 16 | EXCLUDE_PORTS: 443 17 | %ENVIRONMENT_YAML% 18 | command: "/stack/nginx/run.sh" 19 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 20 | tags: 21 | - ec-%DEPLOY_STABILITY_TAG% 22 | - not-files-%DEPLOY_STABILITY_TAG% 23 | # Auto-restart in case container dies unexpectedly 24 | autorestart: always 25 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 26 | autoredeploy: false 27 | # Seqential deployment so that changes can be re-deployed without too much service interruption 28 | sequential_deployment: true 29 | # Container distribution among nodes 30 | deployment_strategy: high_availability 31 | 32 | # HA Proxy for php service scaling 33 | phphaproxy: 34 | image: dockercloud/haproxy:1.6.7 35 | links: 36 | - phpha 37 | ports: 38 | - "9000" 39 | # Publish stats port 40 | - "1936" 41 | environment: 42 | MODE: tcp 43 | TCP_PORTS: 9000 44 | TIMEOUT: connect 500, client 120000, server 120000 45 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 46 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 47 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 48 | tags: 49 | - ec-%DEPLOY_STABILITY_TAG% 50 | - not-files-%DEPLOY_STABILITY_TAG% 51 | # Auto-restart in case container dies unexpectedly 52 | autorestart: always 53 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 54 | autoredeploy: false 55 | # Container distribution among nodes 56 | deployment_strategy: high_availability 57 | # Enable full Tutum API access so that the container can reconfigure itself 58 | roles: 59 | - global 60 | 61 | # The elastically scalable php service for interpreting php code without access to /files 62 | phpha: 63 | image: %DOCKERCLOUD_USER%/%REPO%-php:git-commit-%COMMITSHA% 64 | links: 65 | - mailcatcher 66 | - redisphpsessionhandler 67 | # - memcached 68 | ports: 69 | - "9000" 70 | environment: 71 | TCP_PORTS: '9000' 72 | DISPLAY_PHP_ERRORS: 'off' 73 | LOAD_XDEBUG_EXTENSION: '0' 74 | XDEBUG_DEFAULT_ENABLE: 'off' 75 | RUNNING_LOCALLY: '0' 76 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 77 | PHP_PACKAGE_NAME_VERSION: '7.0' 78 | %ENVIRONMENT_YAML% 79 | working_dir: '/app' 80 | command: "/stack/php/run.sh" 81 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 82 | tags: 83 | - ec-%DEPLOY_STABILITY_TAG% 84 | - not-files-%DEPLOY_STABILITY_TAG% 85 | # Auto-restart in case container dies unexpectedly 86 | autorestart: always 87 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 88 | autoredeploy: false 89 | # Seqential deployment so that changes can be re-deployed without too much service interruption 90 | sequential_deployment: true 91 | # Container distribution among nodes 92 | deployment_strategy: high_availability 93 | 94 | # The redis service used as the PHP session handler for all containers 95 | redisphpsessionhandler: 96 | image: redis 97 | ports: 98 | - "6379" 99 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 100 | tags: 101 | - ec-%DEPLOY_STABILITY_TAG% 102 | - not-files-%DEPLOY_STABILITY_TAG% 103 | # Auto-restart in case container dies unexpectedly 104 | autorestart: always 105 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 106 | autoredeploy: false 107 | 108 | # The single-node php service for interpreting php code with read-write access to user-generated files 109 | # (to support file uploads and other local file manipulations) 110 | phpfiles: 111 | image: %DOCKERCLOUD_USER%/%REPO%-php:git-commit-%COMMITSHA% 112 | links: 113 | - mailcatcher 114 | - redisphpsessionhandler 115 | volumes: 116 | - /files 117 | ports: 118 | - "9000" 119 | environment: 120 | DISPLAY_PHP_ERRORS: 'off' 121 | LOAD_XDEBUG_EXTENSION: '0' 122 | XDEBUG_DEFAULT_ENABLE: 'off' 123 | RUNNING_LOCALLY: '0' 124 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 125 | PHP_PACKAGE_NAME_VERSION: '7.0' 126 | %ENVIRONMENT_YAML% 127 | working_dir: '/app' 128 | command: "/stack/php/run.sh" 129 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 130 | tags: 131 | - ec-%DEPLOY_STABILITY_TAG% 132 | - files-%DEPLOY_STABILITY_TAG% 133 | # Auto-restart in case container dies unexpectedly 134 | autorestart: always 135 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 136 | autoredeploy: false 137 | # Container distribution among nodes 138 | deployment_strategy: emptiest_node 139 | 140 | # Memcached server for serving cached contents via the nginx-memcache plugin 141 | #memcached: 142 | # image: memcached:1.4.22 143 | # ports: 144 | # - "11211" 145 | 146 | # Mailcatcher server for catching outgoing email when not in production 147 | mailcatcher: 148 | image: nisenabe/mailcatcher 149 | expose: 150 | - "25" 151 | ports: 152 | - "1080" 153 | # Set cluster deploy tags to ensure this container is launched inside a cluster and not on a publicly facing node) 154 | tags: 155 | - ec-%DEPLOY_STABILITY_TAG% 156 | - not-files-%DEPLOY_STABILITY_TAG% 157 | # Auto-restart in case container dies unexpectedly 158 | autorestart: always 159 | # Do not update the service when a new version is pushed to the registry (whole stack is redeployed when necessary) 160 | autoredeploy: false 161 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/docker-compose-production.yml: -------------------------------------------------------------------------------- 1 | # Docker compose configuration for production docker-host deployment 2 | version: '2' 3 | services: 4 | 5 | # The nginx server for serving static files directly, cached contents via the memcached server and php files via the php service 6 | web: 7 | image: %DOCKERCLOUD_USER%/%REPO%-nginx:git-commit-%COMMITSHA% 8 | links: 9 | - phphaproxy 10 | - phpfiles 11 | ports: 12 | - "80" 13 | environment: 14 | NGINX_ERROR_LOG_LEVEL: 'notice' 15 | working_dir: '/app' 16 | command: "/stack/nginx/run.sh" 17 | 18 | # HA Proxy for php service scaling 19 | phphaproxy: 20 | image: dockercloud/haproxy:1.5.1 21 | links: 22 | - phpha 23 | ports: 24 | - "9000" 25 | # Publish stats port 26 | - "1936" 27 | environment: 28 | MODE: tcp 29 | TIMEOUT: connect 500, client 120000, server 120000 30 | # Some sort of protection for the stats endpoint (needless to say, you should use a unique secure password in production) 31 | STATS_AUTH: stats:n3v3rg0nnAg1v3y0uup 32 | DOCKER_TLS_VERIFY: ${DOCKER_TLS_VERIFY} 33 | DOCKER_HOST: ${DOCKER_HOST} 34 | DOCKER_CERT_PATH: ${DOCKER_CERT_PATH} 35 | volumes: 36 | - $DOCKER_CERT_PATH:$DOCKER_CERT_PATH 37 | 38 | # The elastically scalable php service for interpreting php code without access to /files 39 | phpha: 40 | image: %DOCKERCLOUD_USER%/%REPO%-php:git-commit-%COMMITSHA% 41 | links: 42 | - mailcatcher 43 | - redisphpsessionhandler 44 | ports: 45 | - "9000" 46 | environment: 47 | TCP_PORTS: '9000' 48 | DISPLAY_PHP_ERRORS: 'off' 49 | XDEBUG_DEFAULT_ENABLE: 'off' 50 | RUNNING_LOCALLY: '0' 51 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 52 | env_file: 53 | - %ENV_FILE_DIR%/.env 54 | working_dir: '/app' 55 | command: "/stack/php/run.sh" 56 | 57 | # The redis service used as the PHP session handler for all containers 58 | redisphpsessionhandler: 59 | image: redis 60 | ports: 61 | - "6379" 62 | 63 | # The single-node php service for interpreting php code with read-write access to user-generated files 64 | # (to support file uploads and other local file manipulations) 65 | phpfiles: 66 | image: %DOCKERCLOUD_USER%/%REPO%-php:git-commit-%COMMITSHA% 67 | links: 68 | - mailcatcher 69 | - redisphpsessionhandler 70 | volumes: 71 | - /files 72 | ports: 73 | - "9000" 74 | environment: 75 | DISPLAY_PHP_ERRORS: 'off' 76 | XDEBUG_DEFAULT_ENABLE: 'off' 77 | RUNNING_LOCALLY: '0' 78 | HHVM: '0' # 1 = Use HHVM instead of the default PHP interpreter 79 | env_file: 80 | - %ENV_FILE_DIR%/.env 81 | working_dir: '/app' 82 | command: "/stack/php/run.sh" 83 | 84 | # Mailcatcher server for catching outgoing email when not in production 85 | mailcatcher: 86 | image: nisenabe/mailcatcher 87 | expose: 88 | - "25" 89 | ports: 90 | - "1080" 91 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/conf.d/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neam/docker-stack/d21afd4638a1786aadf0e916a150abc72b234f06/stacks/neam/debian-php-nginx/stack/nginx/conf.d/.gitkeep -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/conf.d/00-basics.conf: -------------------------------------------------------------------------------- 1 | 2 | # Hide nginx version information. 3 | server_tokens off; 4 | 5 | tcp_nopush on; 6 | tcp_nodelay off; 7 | 8 | client_max_body_size 100m; 9 | client_body_timeout 600s; 10 | 11 | # define the $proxied_https variable based on the forwarded proto as Nginx is not the SSL endpoint 12 | # The name $https cannot be used as the variable is already defined in Nginx core 13 | map $http_x_forwarded_proto $proxied_https { 14 | default off; 15 | https on; 16 | } 17 | 18 | # Enable Gzip compression. 19 | gzip on; 20 | gzip_http_version 1.0; 21 | gzip_comp_level 5; 22 | gzip_min_length 256; 23 | gzip_proxied any; 24 | gzip_vary on; 25 | gzip_types 26 | application/atom+xml 27 | application/javascript 28 | application/x-javascript 29 | application/json 30 | application/rss+xml 31 | application/vnd.ms-fontobject 32 | application/x-font-ttf 33 | application/x-web-app-manifest+json 34 | application/xhtml+xml 35 | application/xml 36 | font/opentype 37 | image/svg+xml 38 | image/x-icon 39 | text/css 40 | text/plain 41 | text/x-component; 42 | # text/html is always compressed by HttpGzipModule 43 | 44 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | 2 | index index.php; 3 | 4 | server { 5 | server_name localhost; 6 | listen 80; 7 | 8 | #Specify a charset 9 | charset utf-8; 10 | 11 | # Framework-specific config 12 | root /app/frontend/www; 13 | 14 | # Attempt the uri, uri+/, then fall back to yii's index.php with args included 15 | location / { 16 | try_files $uri $uri/ /index.php?$args; 17 | } 18 | 19 | # Prevent access to yii protected directories 20 | location ~ ^/(protected|framework|themes/\w+/views) { 21 | deny all; 22 | } 23 | 24 | location ~ \.(hh|php) { 25 | include fastcgi_params; 26 | fastcgi_buffers 256 4k; 27 | fastcgi_param SCRIPT_FILENAME $request_filename; 28 | fastcgi_param HTTPS $proxied_https; 29 | 30 | # for hhvm 31 | fastcgi_keep_conn on; 32 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 33 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 34 | 35 | fastcgi_pass phpha; 36 | } 37 | 38 | location /backend/ { 39 | 40 | alias /app/backend/www/; 41 | 42 | # serve static files direct + allow friendly urls 43 | # Note: The seemingly weird syntax is due to a long-standing bug in nginx: https://trac.nginx.org/nginx/ticket/97 44 | try_files $uri $uri/ /backend//backend/index.php?$args; 45 | 46 | # Prevent access to yii protected directories 47 | location ~ ^/backend/(protected|framework|themes/\w+/views) { 48 | deny all; 49 | } 50 | 51 | location ~ /backend/.+\.(hh|php)$ { 52 | include fastcgi_params; 53 | fastcgi_buffers 256 4k; 54 | fastcgi_param SCRIPT_FILENAME $request_filename; 55 | fastcgi_param HTTPS $proxied_https; 56 | 57 | # for hhvm 58 | fastcgi_keep_conn on; 59 | fastcgi_param NGINX_SCRIPT_NAME $fastcgi_script_name; 60 | fastcgi_param NGINX_DOCUMENT_ROOT $document_root; 61 | 62 | fastcgi_pass phpfiles; 63 | } 64 | 65 | } # / location 66 | 67 | } 68 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/conf.d/php-fpm.conf: -------------------------------------------------------------------------------- 1 | upstream phpha { 2 | server phphaproxy:9000 max_fails=3 fail_timeout=3s; 3 | keepalive 16; 4 | } 5 | 6 | upstream phpfiles { 7 | server phpfiles:9000 max_fails=3 fail_timeout=3s; 8 | keepalive 16; 9 | } 10 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | user nginx; 3 | worker_processes 1; 4 | 5 | error_log /proc/self/fd/2 ${NGINX_ERROR_LOG_LEVEL}; 6 | pid /var/run/nginx.pid; 7 | 8 | 9 | # Tweaked according to max_clients = (worker_processes * worker_connections ) / (X * 2) 10 | # X is however many concurrent connections these clients make to you 11 | # 2 is because you open a connection to what you are proxying 12 | # --> max_clients * X * 2 = worker_connections 13 | 14 | events { 15 | worker_connections 30000; # Key to high performance - have a lot of connections available 16 | } 17 | 18 | # --> worker_rlimit_nofile = worker_connections*2 + some margin 19 | 20 | worker_rlimit_nofile 65000; # Each connection needs a filehandle (or 2 if you are proxying) 21 | 22 | 23 | http { 24 | include /etc/nginx/mime.types; 25 | default_type application/octet-stream; 26 | 27 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 28 | '$status $body_bytes_sent "$http_referer" ' 29 | '"$http_user_agent" "$http_x_forwarded_for"'; 30 | 31 | log_format vhostmain '$host $remote_addr - $remote_user [$time_local] "$request" ' 32 | '$status $body_bytes_sent "$http_referer" ' 33 | '"$http_user_agent" "$http_x_forwarded_for"'; 34 | 35 | access_log /proc/self/fd/2 vhostmain; 36 | 37 | sendfile on; 38 | #tcp_nopush on; 39 | 40 | keepalive_timeout 65; 41 | 42 | #gzip on; 43 | 44 | include /etc/nginx/conf.d/*.conf; 45 | } 46 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/nginx/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is run within the nginx:1.7-based container on start 4 | 5 | # Fail on any error 6 | set -o errexit 7 | 8 | # Copy nginx configuration from app directory to nginx container 9 | 10 | # Remove existing config files 11 | if [ "$(ls /etc/nginx/conf.d/)" ]; then 12 | rm /etc/nginx/conf.d/*.conf 13 | fi 14 | 15 | # Copy custom project include files 16 | if [ "$(ls /stack/nginx/conf.d/)" ]; then 17 | cp -r /stack/nginx/conf.d/* /etc/nginx/conf.d/ 18 | fi 19 | cp /stack/nginx/nginx.conf /etc/nginx/nginx.conf 20 | cp -r /stack/nginx/include /etc/nginx/include 21 | 22 | # Example of using environment variable in configuration at runtime 23 | if [ ! -n "$NGINX_ERROR_LOG_LEVEL" ] ; then 24 | NGINX_ERROR_LOG_LEVEL="warn" 25 | fi 26 | sed -i "s|\${NGINX_ERROR_LOG_LEVEL}|${NGINX_ERROR_LOG_LEVEL}|" /etc/nginx/nginx.conf 27 | 28 | # Run nginx 29 | nginx -g 'daemon off;' 30 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/conf.d-local/local.ini: -------------------------------------------------------------------------------- 1 | opcache.validate_timestamps=on ; 2 | ; xdebug.enable=1 ; 3 | ; xdebug.profiler_enable=1 ; 4 | 5 | ; enable to allow for code coverage reports 6 | ; memory_limit=4G ; 7 | ; xdebug.coverage_enable=1 ; 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/conf.d/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neam/docker-stack/d21afd4638a1786aadf0e916a150abc72b234f06/stacks/neam/debian-php-nginx/stack/php/conf.d/.gitkeep -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/conf.d/00-basics.ini: -------------------------------------------------------------------------------- 1 | ; Logging 2 | display_errors=off 3 | log_errors=on 4 | error_reporting=E_ALL | E_STRICT 5 | 6 | ; Required timezone 7 | date.timezone = UTC 8 | 9 | ; Security 10 | expose_php=off 11 | cgi.fix_pathinfo=0 12 | 13 | memory_limit=128M 14 | 15 | ; Opcache 16 | opcache.memory_consumption=128 17 | opcache.interned_strings_buffer=8 18 | opcache.max_accelerated_files=4000 19 | opcache.validate_timestamps=off 20 | opcache.fast_shutdown=0 21 | opcache.enable_cli=1 22 | 23 | ; Use redis as session handler 24 | session.save_handler = redis 25 | session.save_path = tcp://redisphpsessionhandler:6379 26 | 27 | ; Omit warning NOTICE: PHP message: PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. 28 | always_populate_raw_post_data=-1 29 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/conf.d/app.ini: -------------------------------------------------------------------------------- 1 | ; add your app-specific configuration here - example: 2 | 3 | upload_max_filesize=200M 4 | post_max_size=200M 5 | memory_limit=128M 6 | max_execution_time=300 7 | xdebug.default_enable=${XDEBUG_DEFAULT_ENABLE} 8 | error_reporting=E_ALL 9 | html_errors=on 10 | display_errors=${DISPLAY_PHP_ERRORS} 11 | short_open_tag=on 12 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/conf.d/xdebug.ini: -------------------------------------------------------------------------------- 1 | ; enable xdebug at all 2 | 3 | xdebug.enable=0 4 | 5 | ; remote debugging 6 | 7 | xdebug.remote_enable=1 8 | xdebug.remote_connect_back=1 9 | xdebug.idekey="PHPSTORM" 10 | xdebug.remote_host="localhost" 11 | xdebug.remote_port=9089 12 | 13 | xdebug.remote_autostart=0 14 | xdebug.remote_handler=dbgp 15 | xdebug.remote_mode=req 16 | 17 | ; profiling 18 | 19 | xdebug.profiler_enable=0 20 | xdebug.profiler_enable_trigger=1 21 | xdebug.show_mem_delta=1 22 | xdebug.profiler_output_dir=/app/tmp/xdebug 23 | xdebug.profiler_output_name=callgrind.out.sess-%S.ts-%u.script-%s.req-uri-%R.pid-%p 24 | 25 | ; tracing 26 | 27 | xdebug.trace_format=1 28 | xdebug.trace_output_dir=/app/tmp/xdebug 29 | xdebug.trace_output_name=trace.%s.%R.%p.%u 30 | xdebug.auto_trace=0 31 | 32 | ; error output 33 | 34 | xdebug.show_local_vars=1 35 | xdebug.extended_info = 1 36 | xdebug.cli_color = 1 37 | xdebug.scream = 0 38 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/hhvm/php.ini: -------------------------------------------------------------------------------- 1 | ; hhvm specific 2 | hhvm.log.level = Warning 3 | hhvm.log.always_log_unhandled_exceptions = true 4 | hhvm.log.runtime_error_reporting_level = 8191 5 | hhvm.mysql.typed_results = false -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/hhvm/server.ini: -------------------------------------------------------------------------------- 1 | ; php options 2 | 3 | pid = /var/run/hhvm/pid 4 | 5 | ; hhvm specific 6 | 7 | hhvm.server.port = 9000 8 | hhvm.server.type = fastcgi 9 | hhvm.server.default_document = index.php 10 | ;hhvm.log.use_log_file = true 11 | ;hhvm.log.file = /var/log/hhvm/error.log 12 | hhvm.log.header = true 13 | hhvm.log.natives_stack_trace = true 14 | hhvm.debug.server_error_message = true 15 | hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc 16 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/images/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.0.27, HHVM 3.x.y) built for Debian PHP/Nginx base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack . 4 | # docker push neam/debian-php:fpm-7.0.27-hhvm-3.x.y-for-debian-php-nginx-stack 5 | 6 | FROM neam/debian-php:fpm-7.0.27-hhvm-3.x.y 7 | ARG PHP_PACKAGE_NAME_VERSION=7.0 8 | 9 | MAINTAINER Fredrik Wollsén 10 | 11 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 12 | RUN apt-get update && \ 13 | apt-get upgrade -y -q # 2018-05-09 19:40 14 | 15 | # Install PHP extensions available via apt-get (required for PHP-FPM, but can also be useful to HHVM since default configurations for the extensions are incorporated in the docker image) 16 | RUN apt-get install -y -q \ 17 | php${PHP_PACKAGE_NAME_VERSION}-xdebug \ 18 | php${PHP_PACKAGE_NAME_VERSION}-intl \ 19 | php${PHP_PACKAGE_NAME_VERSION}-gd \ 20 | php${PHP_PACKAGE_NAME_VERSION}-mysqlnd \ 21 | php${PHP_PACKAGE_NAME_VERSION}-sqlite \ 22 | php${PHP_PACKAGE_NAME_VERSION}-mcrypt \ 23 | php${PHP_PACKAGE_NAME_VERSION}-curl \ 24 | php${PHP_PACKAGE_NAME_VERSION}-memcached \ 25 | php${PHP_PACKAGE_NAME_VERSION}-redis \ 26 | php${PHP_PACKAGE_NAME_VERSION}-mongo \ 27 | php${PHP_PACKAGE_NAME_VERSION}-xml \ 28 | php${PHP_PACKAGE_NAME_VERSION}-zip \ 29 | php${PHP_PACKAGE_NAME_VERSION}-mbstring \ 30 | php${PHP_PACKAGE_NAME_VERSION}-mailparse \ 31 | php${PHP_PACKAGE_NAME_VERSION}-apcu && \ 32 | phpenmod mcrypt 33 | 34 | # Install PHP mongodb support - https://github.com/mongodb/mongo-php-driver 35 | #RUN pecl install mongodb 36 | #RUN echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` 37 | 38 | # Install HHVM mongodb support - https://github.com/mongodb/mongo-php-driver 39 | #hhvm-dev 40 | #mkdir hhvm-mongodb \ 41 | #cd hhvm-mongodb \ 42 | #wget ... 43 | #tar -xvzf ../hhvm-mongodb-1.0alpha1.tgz \ 44 | #cd hhvm-mongodb-1.0alpha1 \ 45 | #hphpize \ 46 | #cmake . \ 47 | #make configlib \ 48 | #make -j 16 \ 49 | #make install 50 | #/etc/hhvm/php.ini 51 | #hhvm.dynamic_extensions[mongodb]=mongodb.so 52 | 53 | # ==== 54 | # Install enough to be able to run administrative commands directly from within the php containers 55 | # Useful when using docker exec to emulate the ability to SSH into running containers 56 | # ==== 57 | 58 | # Enable editors and general tools for administration processes 59 | ENV TERM xterm 60 | RUN apt-get install -y -q \ 61 | curl \ 62 | wget \ 63 | htop \ 64 | less \ 65 | jq \ 66 | nano \ 67 | lsb-release gnupg \ 68 | sed \ 69 | telnet \ 70 | net-tools \ 71 | vim 72 | 73 | # Version control systems 74 | RUN apt-get install -y -q \ 75 | git-flow \ 76 | git-svn \ 77 | mercurial \ 78 | subversion 79 | 80 | # Database clients 81 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 82 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 83 | rm mysql-apt-config_0.8.6-1_all.deb && \ 84 | apt-get update && \ 85 | apt-get install -y -q \ 86 | mysql-client 87 | 88 | # Clean apt caches 89 | RUN apt-get clean && \ 90 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 91 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/images/php7.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.1.17, HHVM 3.x.y) built for Debian PHP/Nginx base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/debian-php:fpm-7.1.17-hhvm-3.x.y-for-debian-php-nginx-stack . 4 | # docker push neam/debian-php:fpm-7.1.17-hhvm-3.x.y-for-debian-php-nginx-stack 5 | 6 | FROM neam/debian-php:fpm-7.1.17-hhvm-3.x.y 7 | ARG PHP_PACKAGE_NAME_VERSION=7.1 8 | 9 | MAINTAINER Fredrik Wollsén 10 | 11 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 12 | RUN apt-get update && \ 13 | apt-get upgrade -y -q # 2018-05-09 19:40 14 | 15 | # Install PHP extensions available via apt-get (required for PHP-FPM, but can also be useful to HHVM since default configurations for the extensions are incorporated in the docker image) 16 | RUN apt-get install -y -q \ 17 | php${PHP_PACKAGE_NAME_VERSION}-xdebug \ 18 | php${PHP_PACKAGE_NAME_VERSION}-intl \ 19 | php${PHP_PACKAGE_NAME_VERSION}-gd \ 20 | php${PHP_PACKAGE_NAME_VERSION}-mysqlnd \ 21 | php${PHP_PACKAGE_NAME_VERSION}-sqlite \ 22 | php${PHP_PACKAGE_NAME_VERSION}-mcrypt \ 23 | php${PHP_PACKAGE_NAME_VERSION}-curl \ 24 | php${PHP_PACKAGE_NAME_VERSION}-memcached \ 25 | php${PHP_PACKAGE_NAME_VERSION}-redis \ 26 | php${PHP_PACKAGE_NAME_VERSION}-mongo \ 27 | php${PHP_PACKAGE_NAME_VERSION}-xml \ 28 | php${PHP_PACKAGE_NAME_VERSION}-zip \ 29 | php${PHP_PACKAGE_NAME_VERSION}-mbstring \ 30 | php${PHP_PACKAGE_NAME_VERSION}-mailparse \ 31 | php${PHP_PACKAGE_NAME_VERSION}-apcu && \ 32 | phpenmod mcrypt 33 | 34 | # For compilation of php 7 extensions 35 | #RUN apt-get install -y -q \ 36 | # php7.0-dev 37 | # 38 | # Ice for PHP extension - does not work on PHP 7 39 | #RUN wget https://github.com/ice/framework/archive/1.0.36.zip && \ 40 | # unzip 1.0.36.zip && \ 41 | # cd framework-1.0.36 && \ 42 | # ./install && \ 43 | # cd .. && \ 44 | # rm -r framework-1.0.36# 45 | # 46 | #RUN echo "[ice]\nextension = ice.so" | tee /etc/php/7.0/mods-available/ice.ini && phpenmod ice 47 | 48 | # ==== 49 | # Install enough to be able to run administrative commands directly from within the php containers 50 | # Useful when using docker exec to emulate the ability to SSH into running containers 51 | # ==== 52 | 53 | # Enable editors and general tools for administration processes 54 | ENV TERM xterm 55 | RUN apt-get install -y -q \ 56 | curl \ 57 | wget \ 58 | htop \ 59 | less \ 60 | jq \ 61 | nano \ 62 | lsb-release gnupg \ 63 | sed \ 64 | telnet \ 65 | net-tools \ 66 | vim 67 | 68 | # Version control systems 69 | RUN apt-get install -y -q \ 70 | git-flow \ 71 | git-svn \ 72 | mercurial \ 73 | subversion 74 | 75 | # Database clients 76 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 77 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 78 | rm mysql-apt-config_0.8.6-1_all.deb && \ 79 | apt-get update && \ 80 | apt-get install -y -q \ 81 | mysql-client 82 | 83 | # Clean apt caches 84 | RUN apt-get clean && \ 85 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 86 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/images/php7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for PHP (FPM 7.2.5, HHVM 3.x.y) built for Debian PHP/Nginx base docker-stack 2 | # =============================================================== 3 | # docker build -t neam/debian-php:fpm-7.2.5-hhvm-3.x.y-for-debian-php-nginx-stack . 4 | # docker push neam/debian-php:fpm-7.2.5-hhvm-3.x.y-for-debian-php-nginx-stack 5 | 6 | FROM neam/debian-php:fpm-7.2.5-hhvm-3.x.y 7 | ARG PHP_PACKAGE_NAME_VERSION=7.2 8 | 9 | MAINTAINER Fredrik Wollsén 10 | 11 | # Update the below commented date time to match the time docker fetched the system package information - an update will trigger docker to fetch the information anew 12 | RUN apt-get update && \ 13 | apt-get upgrade -y -q # 2018-05-09 19:40 14 | 15 | # Install PHP extensions available via apt-get (required for PHP-FPM, but can also be useful to HHVM since default configurations for the extensions are incorporated in the docker image) 16 | RUN apt-get install -y -q \ 17 | php${PHP_PACKAGE_NAME_VERSION}-xdebug \ 18 | php${PHP_PACKAGE_NAME_VERSION}-intl \ 19 | php${PHP_PACKAGE_NAME_VERSION}-gd \ 20 | php${PHP_PACKAGE_NAME_VERSION}-mysqlnd \ 21 | php${PHP_PACKAGE_NAME_VERSION}-sqlite \ 22 | php${PHP_PACKAGE_NAME_VERSION}-curl \ 23 | php${PHP_PACKAGE_NAME_VERSION}-memcached \ 24 | php${PHP_PACKAGE_NAME_VERSION}-redis \ 25 | php${PHP_PACKAGE_NAME_VERSION}-mongo \ 26 | php${PHP_PACKAGE_NAME_VERSION}-xml \ 27 | php${PHP_PACKAGE_NAME_VERSION}-zip \ 28 | php${PHP_PACKAGE_NAME_VERSION}-mbstring \ 29 | php${PHP_PACKAGE_NAME_VERSION}-mailparse \ 30 | php${PHP_PACKAGE_NAME_VERSION}-apcu 31 | 32 | # For compilation of php 7 extensions 33 | #RUN apt-get install -y -q \ 34 | # php7.0-dev 35 | # 36 | # Ice for PHP extension - does not work on PHP 7 37 | #RUN wget https://github.com/ice/framework/archive/1.0.36.zip && \ 38 | # unzip 1.0.36.zip && \ 39 | # cd framework-1.0.36 && \ 40 | # ./install && \ 41 | # cd .. && \ 42 | # rm -r framework-1.0.36# 43 | # 44 | #RUN echo "[ice]\nextension = ice.so" | tee /etc/php/7.0/mods-available/ice.ini && phpenmod ice 45 | 46 | # ==== 47 | # Install enough to be able to run administrative commands directly from within the php containers 48 | # Useful when using docker exec to emulate the ability to SSH into running containers 49 | # ==== 50 | 51 | # Enable editors and general tools for administration processes 52 | ENV TERM xterm 53 | RUN apt-get install -y -q \ 54 | curl \ 55 | wget \ 56 | htop \ 57 | less \ 58 | jq \ 59 | nano \ 60 | lsb-release gnupg \ 61 | sed \ 62 | telnet \ 63 | net-tools \ 64 | vim 65 | 66 | # Version control systems 67 | RUN apt-get install -y -q \ 68 | git-flow \ 69 | git-svn \ 70 | mercurial \ 71 | subversion 72 | 73 | # Database clients 74 | RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb && \ 75 | dpkg -i mysql-apt-config_0.8.6-1_all.deb && \ 76 | rm mysql-apt-config_0.8.6-1_all.deb && \ 77 | apt-get update && \ 78 | apt-get install -y -q \ 79 | mysql-client 80 | 81 | # Clean apt caches 82 | RUN apt-get clean && \ 83 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 84 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== HHVM cli ==== 10 | 11 | cp /stack/php/php.ini /etc/hhvm/php.ini # Note: The HHVM cli is here configured to use default php.ini contents that came with php5-fpm 12 | cat /stack/php/hhvm/php.ini >> /etc/hhvm/php.ini # Default hhvm-specific config used for HHVM cli and HHVM fastcgi server 13 | for configfile in /stack/php/conf.d/*; do 14 | cat $configfile >> /etc/hhvm/php.ini 15 | done 16 | 17 | # Add local-only config overrides 18 | if [ "$RUNNING_LOCALLY" == "1" ]; then 19 | for configfile in /stack/php/conf.d-local/*; do 20 | cat $configfile >> /etc/hhvm/php.ini 21 | done 22 | fi 23 | 24 | # Setup config variables only available at runtime 25 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/hhvm/php.ini 26 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/hhvm/php.ini 27 | 28 | # ==== HHVM fastcgi server ==== 29 | 30 | cp /stack/php/php.ini /etc/hhvm/server.ini # Note: The HHVM fastcgi server is here configured to use default php.ini contents that came with php5-fpm 31 | cat /stack/php/hhvm/php.ini >> /etc/hhvm/server.ini # Default hhvm-specific config used for HHVM cli and HHVM fastcgi server 32 | cat /stack/php/hhvm/server.ini >> /etc/hhvm/server.ini # Default hhvm-specific config used for HHVM fastcgi server 33 | for configfile in /stack/php/conf.d/*; do 34 | cat $configfile >> /etc/hhvm/server.ini 35 | done 36 | 37 | # Add local-only config overrides 38 | if [ "$RUNNING_LOCALLY" == "1" ]; then 39 | for configfile in /stack/php/conf.d-local/*; do 40 | cat $configfile >> /etc/hhvm/server.ini 41 | done 42 | fi 43 | 44 | # Setup config variables only available at runtime 45 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/hhvm/server.ini 46 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/hhvm/server.ini 47 | 48 | # Use hhvm for cli 49 | /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60 50 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.0.cli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-CLI ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.0/cli/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.0/cli/conf.d/ 14 | done 15 | 16 | # Add local-only config overrides 17 | if [ "$RUNNING_LOCALLY" == "1" ]; then 18 | for configfile in /stack/php/conf.d-local/*; do 19 | cp $configfile /etc/php/7.0/cli/conf.d/ 20 | done 21 | fi 22 | 23 | # Setup config variables only available at runtime 24 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 25 | rm /etc/php/7.0/cli/conf.d/*xdebug* 26 | fi 27 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.0/cli/conf.d/app.ini 28 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.0/cli/conf.d/app.ini 29 | 30 | # Use php7.0 for cli 31 | /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/php7.0 60 32 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.0.fpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.0/fpm/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.0/fpm/conf.d/ 14 | done 15 | for configfile in /stack/php/php-fpm/pool.d/*; do 16 | cp $configfile /etc/php/7.0/fpm/pool.d/ 17 | done 18 | cp /stack/php/php-fpm/php-fpm.conf /etc/php/7.0/fpm/php-fpm.conf 19 | 20 | # Add local-only config overrides 21 | if [ "$RUNNING_LOCALLY" == "1" ]; then 22 | for configfile in /stack/php/conf.d-local/*; do 23 | cp $configfile /etc/php/7.0/fpm/conf.d/ 24 | done 25 | fi 26 | 27 | # Setup config variables only available at runtime 28 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 29 | rm /etc/php/7.0/fpm/conf.d/*xdebug* 30 | fi 31 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.0/fpm/conf.d/app.ini 32 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.0/fpm/conf.d/app.ini 33 | PHP_CONF_DIR=/etc/php/7.0 34 | sed -i "s|\${PHP_CONF_DIR}|${PHP_CONF_DIR}|" /etc/php/7.0/fpm/php-fpm.conf 35 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.0.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | if [ -d /etc/php/7.0/fpm/ ]; then 12 | /stack/php/inject-config-php7.0.fpm.sh 13 | fi 14 | 15 | if [ -d /etc/php/7.0/cli/ ]; then 16 | /stack/php/inject-config-php7.0.cli.sh 17 | fi 18 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.1.cli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-CLI ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.1/cli/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.1/cli/conf.d/ 14 | done 15 | 16 | # Add local-only config overrides 17 | if [ "$RUNNING_LOCALLY" == "1" ]; then 18 | for configfile in /stack/php/conf.d-local/*; do 19 | cp $configfile /etc/php/7.1/cli/conf.d/ 20 | done 21 | fi 22 | 23 | # Setup config variables only available at runtime 24 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 25 | rm /etc/php/7.1/cli/conf.d/*xdebug* 26 | fi 27 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.1/cli/conf.d/app.ini 28 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.1/cli/conf.d/app.ini 29 | 30 | # Use php7.1 for cli 31 | /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/php7.1 60 32 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.1.fpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.1/fpm/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.1/fpm/conf.d/ 14 | done 15 | for configfile in /stack/php/php-fpm/pool.d/*; do 16 | cp $configfile /etc/php/7.1/fpm/pool.d/ 17 | done 18 | cp /stack/php/php-fpm/php-fpm.conf /etc/php/7.1/fpm/php-fpm.conf 19 | 20 | # Add local-only config overrides 21 | if [ "$RUNNING_LOCALLY" == "1" ]; then 22 | for configfile in /stack/php/conf.d-local/*; do 23 | cp $configfile /etc/php/7.1/fpm/conf.d/ 24 | done 25 | fi 26 | 27 | # Setup config variables only available at runtime 28 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 29 | rm /etc/php/7.1/fpm/conf.d/*xdebug* 30 | fi 31 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.1/fpm/conf.d/app.ini 32 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.1/fpm/conf.d/app.ini 33 | PHP_CONF_DIR=/etc/php/7.1 34 | sed -i "s|\${PHP_CONF_DIR}|${PHP_CONF_DIR}|" /etc/php/7.1/fpm/php-fpm.conf 35 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | if [ -d /etc/php/7.1/fpm/ ]; then 12 | /stack/php/inject-config-php7.1.fpm.sh 13 | fi 14 | 15 | if [ -d /etc/php/7.1/cli/ ]; then 16 | /stack/php/inject-config-php7.1.cli.sh 17 | fi 18 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.2.cli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-CLI ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.2/cli/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.2/cli/conf.d/ 14 | done 15 | 16 | # Add local-only config overrides 17 | if [ "$RUNNING_LOCALLY" == "1" ]; then 18 | for configfile in /stack/php/conf.d-local/*; do 19 | cp $configfile /etc/php/7.2/cli/conf.d/ 20 | done 21 | fi 22 | 23 | # Setup config variables only available at runtime 24 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 25 | rm /etc/php/7.2/cli/conf.d/*xdebug* 26 | fi 27 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.2/cli/conf.d/app.ini 28 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.2/cli/conf.d/app.ini 29 | 30 | # Use php7.2 for cli 31 | /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/php7.2 60 32 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.2.fpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | cp /stack/php/php.ini /etc/php/7.2/fpm/php.ini 12 | for configfile in /stack/php/conf.d/*; do 13 | cp $configfile /etc/php/7.2/fpm/conf.d/ 14 | done 15 | for configfile in /stack/php/php-fpm/pool.d/*; do 16 | cp $configfile /etc/php/7.2/fpm/pool.d/ 17 | done 18 | cp /stack/php/php-fpm/php-fpm.conf /etc/php/7.2/fpm/php-fpm.conf 19 | 20 | # Add local-only config overrides 21 | if [ "$RUNNING_LOCALLY" == "1" ]; then 22 | for configfile in /stack/php/conf.d-local/*; do 23 | cp $configfile /etc/php/7.2/fpm/conf.d/ 24 | done 25 | fi 26 | 27 | # Setup config variables only available at runtime 28 | if [ ! "$LOAD_XDEBUG_EXTENSION" == "1" ]; then 29 | rm /etc/php/7.2/fpm/conf.d/*xdebug* 30 | fi 31 | sed -i "s|\${DISPLAY_PHP_ERRORS}|${DISPLAY_PHP_ERRORS}|" /etc/php/7.2/fpm/conf.d/app.ini 32 | sed -i "s|\${XDEBUG_DEFAULT_ENABLE}|${XDEBUG_DEFAULT_ENABLE}|" /etc/php/7.2/fpm/conf.d/app.ini 33 | PHP_CONF_DIR=/etc/php/7.2 34 | sed -i "s|\${PHP_CONF_DIR}|${PHP_CONF_DIR}|" /etc/php/7.2/fpm/php-fpm.conf 35 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config-php7.2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # ==== PHP-FPM ==== 10 | 11 | if [ -d /etc/php/7.2/fpm/ ]; then 12 | /stack/php/inject-config-php7.2.fpm.sh 13 | fi 14 | 15 | if [ -d /etc/php/7.2/cli/ ]; then 16 | /stack/php/inject-config-php7.2.cli.sh 17 | fi 18 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/inject-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # Inject the appropriate config 10 | if [ "$HHVM" == "1" ]; then 11 | /stack/php/inject-config-hhvm.sh 12 | else 13 | if [ "$PHP_PACKAGE_NAME_VERSION" == "5" ]; then 14 | echo "PHP 5 is no longer included in the Docker stack images" 15 | exit 1; 16 | fi 17 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.0" ]; then 18 | /stack/php/inject-config-php7.0.sh 19 | fi 20 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.1" ]; then 21 | /stack/php/inject-config-php7.1.sh 22 | fi 23 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.2" ]; then 24 | /stack/php/inject-config-php7.2.sh 25 | fi 26 | if [ "$PHP_PACKAGE_NAME_VERSION" == "" ]; then 27 | echo "Error: PHP_PACKAGE_NAME_VERSION is empty so no config could be injected" 28 | exit 1 29 | fi 30 | fi 31 | if [ -f /stack/php/magic.mime ]; then 32 | cat /stack/php/magic.mime >> /etc/magic 33 | fi 34 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/manage-permissions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Fail on any error 4 | set -o errexit 5 | 6 | # Show what the script is doing 7 | set -x 8 | 9 | # Ensures all newly created files will be 775, instead of the debian default of 755 10 | # Overcomes the problem of docker-produced files in a shared-volume not being 11 | # readable or writeable by the non-root user in the docker host. 12 | umask 002 13 | 14 | # Make sure files data media directory exists (only relevant for phpfiles instance) 15 | mkdir -p /files 16 | 17 | # Make sure the directory for local temporary files exists 18 | mkdir -p /local-tmp-files 19 | 20 | if [ "$RUNNING_LOCALLY" == "1" ]; then 21 | 22 | # Work around permission errors locally by making sure that "www-data" uses the same uid and gid as the host volume 23 | TARGET_UID=$(stat -c "%u" /app) 24 | if [ $TARGET_UID != 0 ]; then 25 | usermod -o -u $TARGET_UID www-data 26 | fi 27 | TARGET_GID=$(stat -c "%g" /app) 28 | if [ $TARGET_GID != 0 ]; then 29 | groupmod -o -g $TARGET_GID www-data 30 | fi 31 | 32 | # Prepare writable directories 33 | /stack/src/set-writable-local.sh 34 | 35 | # This needs to be run outside the docker container - does not have any effect when running as part of the start script here... 36 | #/stack/src/set-writable-local-host-volumes.sh 37 | 38 | else 39 | 40 | # Prepare writable directories 41 | cd /app 42 | /stack/src/set-writable-remote.sh 43 | cd - 44 | 45 | fi -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/php-fpm/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ; This file was initially adapated from the output of: (on PHP 5.6) 2 | ; grep -vE '^;|^ *$' php-fpm.conf.default 3 | 4 | [global] 5 | 6 | error_log = /proc/self/fd/2 7 | daemonize = no 8 | 9 | include=${PHP_CONF_DIR}/fpm/pool.d/*.conf 10 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/php-fpm/pool.d/www.conf: -------------------------------------------------------------------------------- 1 | [www] 2 | 3 | ; if we send this to /proc/self/fd/1, it never appears 4 | access.log = /proc/self/fd/2 5 | 6 | user = www-data 7 | group = www-data 8 | 9 | listen = [::]:9000 10 | 11 | ; with around 50mb per php-fpm process, 40 children means about max 2gb RAM being used by php per container 12 | ; scale up the amount of containers per node to use more than this per node. for instance, if the node 13 | ; has 15gb RAM and 10gb should be reserved for php-fpm, use 5 containers per node 14 | pm = dynamic 15 | pm.max_children = 40 16 | pm.start_servers = 16 17 | pm.min_spare_servers = 8 18 | pm.max_spare_servers = 24 19 | 20 | ; send worker output to stdout/stderr 21 | catch_workers_output = yes 22 | 23 | ; make all environment variables available to php-fpm at runtime 24 | clear_env = no 25 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is run within the php containers on start 4 | 5 | # Fail on any error 6 | set -o errexit 7 | 8 | # Show what the script is doing 9 | set -x 10 | 11 | # Copy custom project config overrides 12 | /stack/php/inject-config.sh 13 | 14 | # Manage permissions 15 | /stack/php/manage-permissions.sh 16 | 17 | # Run the desired php cgi process manager (use either php-fpm or hhvm) 18 | if [ "$HHVM" == "1" ]; then 19 | hhvm -m server -c /etc/hhvm/server.ini -u www-data 20 | else 21 | if [ "$PHP_PACKAGE_NAME_VERSION" == "5" ]; then 22 | echo "PHP 5 is no longer included in the Docker stack images" 23 | exit 1; 24 | fi 25 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.0" ]; then 26 | php-fpm7.0 27 | fi 28 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.1" ]; then 29 | php-fpm7.1 30 | fi 31 | if [ "$PHP_PACKAGE_NAME_VERSION" == "7.2" ]; then 32 | php-fpm7.2 33 | fi 34 | if [ "$PHP_PACKAGE_NAME_VERSION" == "" ]; then 35 | echo "Error: PHP_PACKAGE_NAME_VERSION is empty so no config could be injected" 36 | exit 1 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is run within the php containers on start 4 | 5 | # Fail on any error 6 | set -o errexit 7 | 8 | # Show what the script is doing 9 | set -x 10 | 11 | # Copy custom project config overrides 12 | /stack/php/inject-config.sh 13 | 14 | # Manage permissions 15 | /stack/php/manage-permissions.sh 16 | 17 | # Wait for work-dir to exist (docker-sync workaround since the synced contents are not available at container start) 18 | if [ ! "$1" == "" ]; then 19 | while [ ! -d "$1" ] 20 | do 21 | sleep 1 22 | ls -l "/app" 23 | done 24 | ls -l "$1" 25 | cd "$1" 26 | fi 27 | 28 | # Start a shell 29 | bash 30 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/php/yet-unused/newrelic.ini: -------------------------------------------------------------------------------- 1 | extension=newrelic.so 2 | newrelic.appname=${NEW_RELIC_APP_NAME} 3 | newrelic.license=${NEW_RELIC_LICENSE_KEY} 4 | newrelic.logfile=${NEW_RELIC_LOG} 5 | newrelic.daemon.logfile=${NEW_RELIC_DAEMON_LOG} 6 | newrelic.daemon.location=${NEW_RELIC_PATH}/bin/newrelic-daemon 7 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # fail on any error 4 | set -o errexit 5 | 6 | # always run from project root 7 | script_path=`dirname $0` 8 | cd $script_path/.. 9 | 10 | # run actual command 11 | echo "Starting /bin/bash in a new shell container... " 12 | docker-compose -f docker-compose.yml run --rm shell 13 | 14 | exit 0 15 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/src/set-writable-local-host-volumes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # shared with the host 4 | chmod -R g+rw .files/ 5 | chmod -R g+rw frontend/app/runtime 6 | chmod -R g+rw frontend/www/assets 7 | chmod -R g+rw backend/app/runtime 8 | chmod -R g+rw backend/www/assets 9 | mkdir -p tmp/xdebug/ 10 | chmod -R g+rw tmp/xdebug/ 11 | 12 | exit 0 -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/src/set-writable-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # directories within containers 4 | chown -R www-data /local-tmp-files 5 | chmod -R g+rw /local-tmp-files 6 | 7 | exit 0 8 | -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/src/set-writable-remote.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | chmod -R 777 /local-tmp-files 4 | if [ -d "/files" ]; then 5 | chmod -R 777 /files 6 | fi 7 | chmod -R 777 frontend/app/runtime 8 | chmod -R 777 frontend/www/assets 9 | chmod -R 777 backend/app/runtime 10 | chmod -R 777 backend/www/assets 11 | 12 | exit 0 -------------------------------------------------------------------------------- /stacks/neam/debian-php-nginx/stack/url.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$DOCKERSTACK_DEBUG" == "1" ]; then 4 | set -x; 5 | fi 6 | 7 | SERVICE_NAME=$1 8 | PORT=$2 9 | VIRTUAL_HOST=$3 10 | URL_PATH="${@:4}" 11 | 12 | if [ "$SERVICE_NAME" == "" ]; then 13 | SERVICE_NAME=router 14 | fi 15 | 16 | if [ "$PORT" == "" ]; then 17 | PORT=80 18 | fi 19 | 20 | if [ "$VIRTUAL_HOST" == "" ] || [ "$VIRTUAL_HOST" == "-" ]; then 21 | VIRTUAL_HOST=$(echo $DOCKER_HOST | sed 's/tcp:\/\///' | sed 's/:[0-9.]*//'); 22 | fi 23 | 24 | HTTP_PORT=$(docker-compose port $SERVICE_NAME $PORT | sed 's/[0-9.]*://'); 25 | if [ "HTTP_PORT" == "" ]; then 26 | echo "Could not find the corresponding HTTP_PORT" 27 | exit 1 28 | fi 29 | URL="http://$VIRTUAL_HOST:$HTTP_PORT"; 30 | URL=$URL"$URL_PATH"; 31 | echo $URL; 32 | --------------------------------------------------------------------------------