From 64f15f7b3b42c3918fb686bd886d819ac435619f Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 07:43:32 -0400 Subject: [PATCH 01/68] Create .travis.yml First stab at a travis.yml file --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8fcbac4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php +php: + - '5.5' # Ubuntu Trusty default + - '5.6' # MacOS default + - '7.0' + - '7.1' + +install: + - composer install + +test: + - bin/terra status From 9d9241b9263dc8432ac2376123f7e1bb8b96822d Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 07:49:30 -0400 Subject: [PATCH 02/68] Fixing script for travis. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8fcbac4..3e89d67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: install: - composer install + - ls -la -test: +script: - bin/terra status From d82d7f45a589ab505b353f4444867c0b0d39f0ac Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 07:51:57 -0400 Subject: [PATCH 03/68] Don't forget to turn on docker! --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3e89d67..4c4573b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ php: - '7.0' - '7.1' +services: + - docker + install: - composer install - ls -la From 4093ef6c920c6328c7884b57f852f2fabbb2f964 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 08:17:48 -0400 Subject: [PATCH 04/68] Add an app and an environment. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4c4573b..5c5975f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,7 @@ install: - ls -la script: + - bin/terra app:add drupal8 git@github.com:terra-ops/example-drupal.git + - bin/terra env:add drupal8 travis --enable - bin/terra status + From 0b90ec9b772392f03eb41d98b48fd20390ebee1e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 08:20:15 -0400 Subject: [PATCH 05/68] Add a description, its required --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5c5975f..8bb6c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ install: - ls -la script: - - bin/terra app:add drupal8 git@github.com:terra-ops/example-drupal.git + - bin/terra app:add drupal8 git@github.com:terra-ops/example-drupal.git 'sample app' - bin/terra env:add drupal8 travis --enable - bin/terra status From ac9eb9ca63a301fc6dc1999ab74b209d85a9088f Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 08:21:38 -0400 Subject: [PATCH 06/68] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8bb6c21..9d1b17c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - ls -la script: + - bin/terra - bin/terra app:add drupal8 git@github.com:terra-ops/example-drupal.git 'sample app' - bin/terra env:add drupal8 travis --enable - bin/terra status From 0e82d7bb3b109e255647eb014f02a21c7850221f Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 08:51:41 -0400 Subject: [PATCH 07/68] Test environment creation options in app:add. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d1b17c..bdb66b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: script: - bin/terra - - bin/terra app:add drupal8 git@github.com:terra-ops/example-drupal.git 'sample app' - - bin/terra env:add drupal8 travis --enable + - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --create-environment --environment-name=demo + - bin/terra environment:enable drupal demo - bin/terra status From b2e046e23146c2236196769fcc9a23c1a1ba2983 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 08:59:13 -0400 Subject: [PATCH 08/68] Separate app:add and environment:add commands. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bdb66b9..26f384c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: script: - bin/terra - - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --create-environment --environment-name=demo - - bin/terra environment:enable drupal demo + - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --host=local.computer -n + - terra e:a drupal demo --enable -n - bin/terra status From dee65b060f2ae8892a3ceedd0463f666595153db Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sun, 25 Jun 2017 09:16:13 -0400 Subject: [PATCH 09/68] bin/terra, not terra. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 26f384c..25b9d67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ install: script: - bin/terra - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - - terra e:a drupal demo --enable -n + - bin/terra e:a drupal demo --enable -n - bin/terra status From 1aff38229119109fe799a8fe5bd5c0ead7626f9e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 13:54:07 -0400 Subject: [PATCH 10/68] Add argument for path of environment source files. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 25b9d67..611a362 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ install: script: - bin/terra - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - - bin/terra e:a drupal demo --enable -n + - bin/terra e:a drupal demo demo --enable -n - bin/terra status From 91afbbfec7b5824798eff278e47c5e62cd903f6b Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 13:58:40 -0400 Subject: [PATCH 11/68] Use http for cloning. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 611a362..88c309e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: script: - bin/terra - - bin/terra app:add drupal git@github.com:terra-ops/example-drupal.git --description='sample app' --host=local.computer -n + - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - bin/terra e:a drupal demo demo --enable -n - bin/terra status From 21886db5bf8c7f644ba1a0bd0e26c7e863af2f30 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:12:25 -0400 Subject: [PATCH 12/68] Add drush as a dependency. --- composer.json | 3 +- composer.lock | 745 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 731 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 37ea6ee..0adc51c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "cpliakas/git-wrapper": "~1.4", "teqneers/php-stream-wrapper-for-git": "~1.0", "videlalvaro/php-amqplib": "2.2.*", - "guzzlehttp/guzzle": "~6.0" + "guzzlehttp/guzzle": "~6.0", + "drush/drush": "^8.1" }, "authors": [ { diff --git a/composer.lock b/composer.lock index 8820253..6d86a7e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,106 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f0988a3267502021a9ad880177068a1e", - "content-hash": "fe5e5472839f10992e7d9da9c0a19e28", + "content-hash": "d87624377c4edace446baabeca12a827", "packages": [ + { + "name": "consolidation/annotated-command", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/consolidation/annotated-command.git", + "reference": "ed279df30b9386fd8e523003dc679421a87c52e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/ed279df30b9386fd8e523003dc679421a87c52e0", + "reference": "ed279df30b9386fd8e523003dc679421a87c52e0", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "phpdocumentor/reflection-docblock": "~2", + "psr/log": "~1.0", + "symfony/console": "~2.5|~3.0", + "symfony/finder": "~2.5|~3.0" + }, + "require-dev": { + "consolidation/output-formatters": "~1", + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^1.0", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\AnnotatedCommand\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Initialize Symfony Console commands from annotated command class methods.", + "time": "2016-05-21T13:25:52+00:00" + }, + { + "name": "consolidation/output-formatters", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/consolidation/output-formatters.git", + "reference": "6428d8fb30c9ed3b96314580808b3e4415b46dd9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/6428d8fb30c9ed3b96314580808b3e4415b46dd9", + "reference": "6428d8fb30c9ed3b96314580808b3e4415b46dd9", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "symfony/console": "~2.5|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^1.0", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Consolidation\\OutputFormatters\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Format text by applying transformations provided by plug-in formatters.", + "time": "2016-05-20T04:17:55+00:00" + }, { "name": "cpliakas/git-wrapper", "version": "1.6.1", @@ -60,7 +157,143 @@ "keywords": [ "git" ], - "time": "2015-11-11 15:45:43" + "time": "2015-11-11T15:45:43+00:00" + }, + { + "name": "dnoegel/php-xdg-base-dir", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/dnoegel/php-xdg-base-dir.git", + "reference": "265b8593498b997dc2d31e75b89f053b5cc9621a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/265b8593498b997dc2d31e75b89f053b5cc9621a", + "reference": "265b8593498b997dc2d31e75b89f053b5cc9621a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "@stable" + }, + "type": "project", + "autoload": { + "psr-4": { + "XdgBaseDir\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "implementation of xdg base directory specification for php", + "time": "2014-10-24T07:27:01+00:00" + }, + { + "name": "drush/drush", + "version": "8.1.3", + "source": { + "type": "git", + "url": "https://github.com/drush-ops/drush.git", + "reference": "fec57947d9cc3ae8978bd747cb3d60ec9864e912" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/drush-ops/drush/zipball/fec57947d9cc3ae8978bd747cb3d60ec9864e912", + "reference": "fec57947d9cc3ae8978bd747cb3d60ec9864e912", + "shasum": "" + }, + "require": { + "consolidation/annotated-command": "~1.0.0-beta6", + "consolidation/output-formatters": "~1.0.0-beta5", + "pear/console_table": "~1.3.0", + "php": ">=5.4.5", + "psr/log": "~1.0", + "psy/psysh": "~0.6", + "symfony/console": "~2.7", + "symfony/finder": "~2.7", + "symfony/var-dumper": "~2.7", + "symfony/yaml": "~2.3" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/process": "2.7.*" + }, + "suggest": { + "drush/config-extra": "Provides configuration workflow commands, such as config-merge.", + "ext-pcntl": "*" + }, + "bin": [ + "drush", + "drush.launcher", + "drush.php", + "drush.bat", + "drush.complete.sh" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Drush": "lib/", + "Consolidation": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "Moshe Weitzman", + "email": "weitzman@tejasa.com" + }, + { + "name": "Owen Barton", + "email": "drupal@owenbarton.com" + }, + { + "name": "Mark Sonnabaum", + "email": "marksonnabaum@gmail.com" + }, + { + "name": "Antoine Beaupré", + "email": "anarcat@koumbit.org" + }, + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + }, + { + "name": "Jonathan Araña Cruz", + "email": "jonhattan@faita.net" + }, + { + "name": "Jonathan Hedstrom", + "email": "jhedstrom@gmail.com" + }, + { + "name": "Christopher Gervais", + "email": "chris@ergonlogic.com" + }, + { + "name": "Dave Reid", + "email": "dave@davereid.net" + }, + { + "name": "Damian Lee", + "email": "damiankloip@googlemail.com" + } + ], + "description": "Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.", + "homepage": "http://www.drush.org", + "time": "2016-07-18T22:02:09+00:00" }, { "name": "guzzlehttp/guzzle", @@ -122,7 +355,7 @@ "rest", "web service" ], - "time": "2015-11-23 00:47:50" + "time": "2015-11-23T00:47:50+00:00" }, { "name": "guzzlehttp/promises", @@ -173,7 +406,7 @@ "keywords": [ "promise" ], - "time": "2015-10-15 22:28:00" + "time": "2015-10-15T22:28:00+00:00" }, { "name": "guzzlehttp/psr7", @@ -231,7 +464,249 @@ "stream", "uri" ], - "time": "2016-02-18 21:54:00" + "time": "2016-02-18T21:54:00+00:00" + }, + { + "name": "jakub-onderka/php-console-color", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/JakubOnderka/PHP-Console-Color.git", + "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/e0b393dacf7703fc36a4efc3df1435485197e6c1", + "reference": "e0b393dacf7703fc36a4efc3df1435485197e6c1", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "jakub-onderka/php-code-style": "1.0", + "jakub-onderka/php-parallel-lint": "0.*", + "jakub-onderka/php-var-dump-check": "0.*", + "phpunit/phpunit": "3.7.*", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "JakubOnderka\\PhpConsoleColor": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "jakub.onderka@gmail.com", + "homepage": "http://www.acci.cz" + } + ], + "time": "2014-04-08T15:00:19+00:00" + }, + { + "name": "jakub-onderka/php-console-highlighter", + "version": "v0.3.2", + "source": { + "type": "git", + "url": "https://github.com/JakubOnderka/PHP-Console-Highlighter.git", + "reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/7daa75df45242c8d5b75a22c00a201e7954e4fb5", + "reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5", + "shasum": "" + }, + "require": { + "jakub-onderka/php-console-color": "~0.1", + "php": ">=5.3.0" + }, + "require-dev": { + "jakub-onderka/php-code-style": "~1.0", + "jakub-onderka/php-parallel-lint": "~0.5", + "jakub-onderka/php-var-dump-check": "~0.1", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "JakubOnderka\\PhpConsoleHighlighter": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "acci@acci.cz", + "homepage": "http://www.acci.cz/" + } + ], + "time": "2015-04-20T18:58:01+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v3.0.6", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "0808939f81c1347a3c8a82a5925385a08074b0f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0808939f81c1347a3c8a82a5925385a08074b0f1", + "reference": "0808939f81c1347a3c8a82a5925385a08074b0f1", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.0|~5.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2017-06-28T20:53:48+00:00" + }, + { + "name": "pear/console_table", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_Table.git", + "reference": "64100b9ee81852f4fa17823e55d0b385a544f976" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_Table/zipball/64100b9ee81852f4fa17823e55d0b385a544f976", + "reference": "64100b9ee81852f4fa17823e55d0b385a544f976", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "suggest": { + "pear/Console_Color2": ">=0.1.2" + }, + "type": "library", + "autoload": { + "classmap": [ + "Table.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jan Schneider", + "homepage": "http://pear.php.net/user/yunosh" + }, + { + "name": "Tal Peer", + "homepage": "http://pear.php.net/user/tal" + }, + { + "name": "Xavier Noguer", + "homepage": "http://pear.php.net/user/xnoguer" + }, + { + "name": "Richard Heyes", + "homepage": "http://pear.php.net/user/richard" + } + ], + "description": "Library that makes it easy to build console style tables.", + "homepage": "http://pear.php.net/package/Console_Table/", + "keywords": [ + "console" + ], + "time": "2016-01-21T16:14:31+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "reference": "e6a969a640b00d8daa3c66518b0405fb41ae0c4b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2016-01-25T08:17:30+00:00" }, { "name": "psr/http-message", @@ -280,7 +755,127 @@ "request", "response" ], - "time": "2015-05-04 20:22:00" + "time": "2015-05-04T20:22:00+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "psy/psysh", + "version": "v0.8.8", + "source": { + "type": "git", + "url": "https://github.com/bobthecow/psysh.git", + "reference": "fe65c30cbc55c71e61ba3a38b5a581149be31b8e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/fe65c30cbc55c71e61ba3a38b5a581149be31b8e", + "reference": "fe65c30cbc55c71e61ba3a38b5a581149be31b8e", + "shasum": "" + }, + "require": { + "dnoegel/php-xdg-base-dir": "0.1", + "jakub-onderka/php-console-highlighter": "0.3.*", + "nikic/php-parser": "~1.3|~2.0|~3.0", + "php": ">=5.3.9", + "symfony/console": "~2.3.10|^2.4.2|~3.0", + "symfony/var-dumper": "~2.7|~3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~1.11", + "hoa/console": "~3.16|~1.14", + "phpunit/phpunit": "~4.4|~5.0", + "symfony/finder": "~2.1|~3.0" + }, + "suggest": { + "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", + "ext-pdo-sqlite": "The doc command requires SQLite to work.", + "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.", + "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history.", + "hoa/console": "A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit." + }, + "bin": [ + "bin/psysh" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.8.x-dev" + } + }, + "autoload": { + "files": [ + "src/Psy/functions.php" + ], + "psr-4": { + "Psy\\": "src/Psy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Justin Hileman", + "email": "justin@justinhileman.info", + "homepage": "http://justinhileman.com" + } + ], + "description": "An interactive shell for modern PHP.", + "homepage": "http://psysh.org", + "keywords": [ + "REPL", + "console", + "interactive", + "shell" + ], + "time": "2017-06-24T06:16:19+00:00" }, { "name": "symfony/config", @@ -330,7 +925,7 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:33:41" + "time": "2016-01-03T15:33:41+00:00" }, { "name": "symfony/console", @@ -390,7 +985,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-01-14 08:33:16" + "time": "2016-01-14T08:33:16+00:00" }, { "name": "symfony/event-dispatcher", @@ -450,7 +1045,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-01-27T05:14:46+00:00" }, { "name": "symfony/filesystem", @@ -499,7 +1094,56 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-01-13 10:28:07" + "time": "2016-01-13T10:28:07+00:00" + }, + { + "name": "symfony/finder", + "version": "v2.8.22", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "4f4e84811004e065a3bb5ceeb1d9aa592630f9ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/4f4e84811004e065a3bb5ceeb1d9aa592630f9ad", + "reference": "4f4e84811004e065a3bb5ceeb1d9aa592630f9ad", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2017-06-01T20:52:29+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -558,7 +1202,7 @@ "portable", "shim" ], - "time": "2016-01-20 09:13:37" + "time": "2016-01-20T09:13:37+00:00" }, { "name": "symfony/process", @@ -607,7 +1251,75 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-01-06 09:59:23" + "time": "2016-01-06T09:59:23+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v2.8.22", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "8108f6200e8a1cf999df2691431a2d71e6db1152" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/8108f6200e8a1cf999df2691431a2d71e6db1152", + "reference": "8108f6200e8a1cf999df2691431a2d71e6db1152", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + }, + "require-dev": { + "ext-iconv": "*", + "twig/twig": "~1.34|~2.4" + }, + "suggest": { + "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", + "ext-symfony_debug": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony mechanism for exploring and dumping PHP variables", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "time": "2017-06-02T08:28:06+00:00" }, { "name": "symfony/yaml", @@ -656,7 +1368,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-01-13 10:28:07" + "time": "2016-01-13T10:28:07+00:00" }, { "name": "teqneers/php-stream-wrapper-for-git", @@ -706,7 +1418,7 @@ "stream-wrapper", "streamwrapper" ], - "time": "2015-11-26 15:23:29" + "time": "2015-11-26T15:23:29+00:00" }, { "name": "videlalvaro/php-amqplib", @@ -751,7 +1463,8 @@ "queue", "rabbitmq" ], - "time": "2013-12-22 12:49:53" + "abandoned": "php-amqplib/php-amqplib", + "time": "2013-12-22T12:49:53+00:00" } ], "packages-dev": [], From d6f41cf3530f2347664b75273adfe3ba05792474 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:13:13 -0400 Subject: [PATCH 13/68] Adding symlink to vendor/drush/drush/drush --- bin/drush | 1 + 1 file changed, 1 insertion(+) create mode 120000 bin/drush diff --git a/bin/drush b/bin/drush new file mode 120000 index 0000000..2e2ad4d --- /dev/null +++ b/bin/drush @@ -0,0 +1 @@ +../vendor/drush/drush/drush \ No newline at end of file From e19396172c0fa8cb1fb821695feb8be0b9cc6926 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:14:35 -0400 Subject: [PATCH 14/68] Add alias for terra and drush. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 88c309e..157f97a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ services: install: - composer install + - alias terra=bin/terra + - alias drush=bin/drush - ls -la script: From 7612667f79bf7175d70fb6002b2309148253d100 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:19:41 -0400 Subject: [PATCH 15/68] Use symlinks to make executable. --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 157f97a..4ded307 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,12 +10,13 @@ services: install: - composer install - - alias terra=bin/terra - - alias drush=bin/drush + - sudo ln -s {$PWD}/bin/terra /usr/local/bin/terra + - sudo ln -s {$PWD}/vendor/drush/drush/drush - ls -la script: - - bin/terra + - terra + - drush - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - bin/terra e:a drupal demo demo --enable -n - bin/terra status From 59a1f6117270e6d1a9f3f93550b05885d492f6b2 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:22:49 -0400 Subject: [PATCH 16/68] Fix symlinks --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ded307..05c6b39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ services: install: - composer install - - sudo ln -s {$PWD}/bin/terra /usr/local/bin/terra - - sudo ln -s {$PWD}/vendor/drush/drush/drush + - sudo ln -s $PWD/bin/terra /usr/local/bin/terra + - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/terra - ls -la script: From 44ce8fc008f261d1c1fb60aea3122f179d850871 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:25:01 -0400 Subject: [PATCH 17/68] Fix symlinks --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 05c6b39..637cb12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ services: install: - composer install - sudo ln -s $PWD/bin/terra /usr/local/bin/terra - - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/terra + - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la script: From 821cddc23a8cadaef7e166f216c4d6a4f697a0c0 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:30:16 -0400 Subject: [PATCH 18/68] Set SSH config: StrictHostKeyChecking no --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 637cb12..dd0f511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: - sudo ln -s $PWD/bin/terra /usr/local/bin/terra - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la + - echo "Host * \n StrictHostKeyChecking no" >> ~/.ssh/config script: - terra From ab45cd1bfbe68868d0316a9da0c5cd5f6957212b Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:37:19 -0400 Subject: [PATCH 19/68] Echo the ssh config file. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index dd0f511..5254581 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ install: - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la - echo "Host * \n StrictHostKeyChecking no" >> ~/.ssh/config + - cat ~/.ssh/config script: - terra From cdd6c960bf3b2dcc0a2bef020a5ae54fbf5ff569 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:43:52 -0400 Subject: [PATCH 20/68] Fixing the SSH config generation. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5254581..3cd9b9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ install: - sudo ln -s $PWD/bin/terra /usr/local/bin/terra - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la - - echo "Host * \n StrictHostKeyChecking no" >> ~/.ssh/config - - cat ~/.ssh/config + - echo "StrictHostKeyChecking no" >> ~/.ssh/config script: - terra From 1fca5314d21ca88f586d38a33c048d8caba69476 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 14:52:37 -0400 Subject: [PATCH 21/68] Generate an SSH key so we can use drush via SSH. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cd9b9f..af02614 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ install: - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la - echo "StrictHostKeyChecking no" >> ~/.ssh/config + - ssh-keygen -t rsa -N "" -f $PWD/.ssh/id_rsa script: - terra @@ -21,4 +22,4 @@ script: - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - bin/terra e:a drupal demo demo --enable -n - bin/terra status - + From 5771d57750d27983319fc2b1433853647e84058c Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 15:12:04 -0400 Subject: [PATCH 22/68] Wrong folder. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af02614..3cdd8cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la - echo "StrictHostKeyChecking no" >> ~/.ssh/config - - ssh-keygen -t rsa -N "" -f $PWD/.ssh/id_rsa + - ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsas script: - terra From 3bdbdfef8e2191abd93e8dac020b9322b2219146 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 15:26:31 -0400 Subject: [PATCH 23/68] Output docker compose file, trying to figure out what's wrong with ssh keys. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cdd8cb..59a766f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,9 @@ script: - terra - drush - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - - bin/terra e:a drupal demo demo --enable -n + - bin/terra e:a drupal demo demo -n + - cat ~/.terra/environments/drupal/drupal-demo/docker-compose.yml + + - bin/terra e:e drupal demo - bin/terra status From b28f9e9f6802f87aa4db765f4ad87dbf0ce65c49 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 15:26:50 -0400 Subject: [PATCH 24/68] list ssh folder. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 59a766f..a049af5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: - ls -la - echo "StrictHostKeyChecking no" >> ~/.ssh/config - ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsas + - ls -la ~/.ssh script: - terra From 885cabbd080fea5a66a7a410df66d3448434373c Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 15:31:02 -0400 Subject: [PATCH 25/68] Bad filename. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a049af5..c773f1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: - sudo ln -s $PWD/vendor/drush/drush/drush /usr/local/bin/drush - ls -la - echo "StrictHostKeyChecking no" >> ~/.ssh/config - - ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsas + - ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa - ls -la ~/.ssh script: From d6d91e9fd8cada4b1e924112d186f22cf7c4f14c Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 29 Jun 2017 16:34:46 -0400 Subject: [PATCH 26/68] Use lowercase "z" flags in docker-compose volumes. --- src/terra/Factory/EnvironmentFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terra/Factory/EnvironmentFactory.php b/src/terra/Factory/EnvironmentFactory.php index b07e4a0..9e52ab9 100644 --- a/src/terra/Factory/EnvironmentFactory.php +++ b/src/terra/Factory/EnvironmentFactory.php @@ -333,7 +333,7 @@ public function getDockerComposeArray() 'database', ), 'volumes' => array( - "{$this->environment->path}:/app:Z", + "{$this->environment->path}:/app:z", ), 'environment' => array( 'HOST_UID' => posix_getuid(), @@ -366,8 +366,8 @@ public function getDockerComposeArray() '22', ), 'volumes' => array( - "$document_root:/var/www/html", - "$source_root:/source", + "$document_root:/var/www/html:z", + "$source_root:/source:z", ), 'environment' => array( 'AUTHORIZED_KEYS' => $ssh_authorized_keys, From 22de1dfd122bb3aa612e2d9f379eeb6105079444 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 10:55:00 -0400 Subject: [PATCH 27/68] Adding terra/drupal Dockerfile directly to terra-cli project. --- docker/drupal/Dockerfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docker/drupal/Dockerfile diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile new file mode 100644 index 0000000..d697032 --- /dev/null +++ b/docker/drupal/Dockerfile @@ -0,0 +1,28 @@ +# Officially maintained by Docker. +FROM drupal:7-apache + +# terra/drupal (this file) maintained by THINKDROP +MAINTAINER Jon Pugh + +# ARG allows values to be passed from `docker build` command. +# Use `id -u` to determine your current UID. +# Terra CLI will build these for us soon, but for now, use this command: +# `docker build -t terra/drupal --build-arg TERRA_UID=501 .` +ARG TERRA_UID=1000 + +# TERRA_GID will default to TERRA_UID, unless passed as a build-arg to `docker-build`. +ARG TERRA_GID=$TERRA_UID + +ENV TERRA_USER=terra +ENV TERRA_HOME=/var/terra + +RUN echo "Creating user $TERRA_USER with UID $TERRA_UID and GID $TERRA_GID and HOME of $TERRA_HOME" +RUN addgroup --gid $TERRA_UID $TERRA_USER +RUN adduser --uid $TERRA_UID --gid $TERRA_GID --system --home $TERRA_HOME $TERRA_USER +RUN adduser $TERRA_USER www-data + +USER $TERRA_USER +WORKDIR $TERRA_HOME +VOLUME $TERRA_HOME +VOLUME /var/www/html/ +EXPOSE 80 \ No newline at end of file From 2eaa3e70a9987251e573ba32c7e066c6777c7489 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 11:30:28 -0400 Subject: [PATCH 28/68] Fixing permissions issues caused by running as $TERRA_USER: Install sudo and configure sudoers to allow $TERRA_USER to run sudo apache2-foreground. --- docker/drupal/Dockerfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index d697032..48d8a4d 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -16,13 +16,28 @@ ARG TERRA_GID=$TERRA_UID ENV TERRA_USER=terra ENV TERRA_HOME=/var/terra +# We need to install sudo so we can allow terra user to start apache. +# @TODO: Add this to a new upstream image. +RUN apt-get -qq update && apt-get -qq -y install \ + git \ + sudo \ + zip + RUN echo "Creating user $TERRA_USER with UID $TERRA_UID and GID $TERRA_GID and HOME of $TERRA_HOME" RUN addgroup --gid $TERRA_UID $TERRA_USER RUN adduser --uid $TERRA_UID --gid $TERRA_GID --system --home $TERRA_HOME $TERRA_USER RUN adduser $TERRA_USER www-data +RUN echo "Granting sudo apache2-foreground access to $TERRA_USER" +RUN echo "Defaults:$TERRA_USER !requiretty \n$TERRA_USER ALL=NOPASSWD: /usr/local/bin/apache2-foreground" >> /etc/sudoers.d/$TERRA_USER + +RUN cat /etc/sudoers.d/$TERRA_USER + USER $TERRA_USER WORKDIR $TERRA_HOME VOLUME $TERRA_HOME VOLUME /var/www/html/ -EXPOSE 80 \ No newline at end of file +EXPOSE 80 + +# Default for drupal:7-apache is apache2-foreground. We want to run as Terra user so we use sudo. +CMD ["sudo", "apache2-foreground"] \ No newline at end of file From 928b10b70f4fd6138f9d18939e7e1c71caa2de2d Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 12:01:21 -0400 Subject: [PATCH 29/68] - Adding our own apache vhost config file so we can configure environment variables. - Adding our own entrypoint so we can set apache environment variables, launch apache then tail logs. --- docker/drupal/Dockerfile | 18 +++++++++++++++++- docker/drupal/apache-vhost.conf | 25 +++++++++++++++++++++++++ docker/drupal/terra-entrypoint.sh | 14 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 docker/drupal/apache-vhost.conf create mode 100644 docker/drupal/terra-entrypoint.sh diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 48d8a4d..8d35781 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -31,6 +31,22 @@ RUN adduser $TERRA_USER www-data RUN echo "Granting sudo apache2-foreground access to $TERRA_USER" RUN echo "Defaults:$TERRA_USER !requiretty \n$TERRA_USER ALL=NOPASSWD: /usr/local/bin/apache2-foreground" >> /etc/sudoers.d/$TERRA_USER +# Add our own Apache configuration +COPY apache-vhost.conf /etc/apache2/sites-available/000-default.conf + +# Set ownership of /etc/apache2/envvars so hubdrop-entrypoint.sh can write to it +RUN chown $TERRA_USER /etc/apache2/envvars + +# Prepare log file +RUN touch /var/log/terra +RUN chown $TERRA_USER /var/log/terra +RUN chgrp $TERRA_USER /var/log/terra + +# Add our own entrypoint +COPY terra-entrypoint.sh /usr/local/bin/terra-entrypoint +RUN chmod +x /usr/local/bin/terra-entrypoint + + RUN cat /etc/sudoers.d/$TERRA_USER USER $TERRA_USER @@ -40,4 +56,4 @@ VOLUME /var/www/html/ EXPOSE 80 # Default for drupal:7-apache is apache2-foreground. We want to run as Terra user so we use sudo. -CMD ["sudo", "apache2-foreground"] \ No newline at end of file +CMD ["/usr/local/bin/terra-entrypoint"] \ No newline at end of file diff --git a/docker/drupal/apache-vhost.conf b/docker/drupal/apache-vhost.conf new file mode 100644 index 0000000..654a7ae --- /dev/null +++ b/docker/drupal/apache-vhost.conf @@ -0,0 +1,25 @@ + + + ServerName ${TERRA_ENVIRONMENT_URL} + DocumentRoot /var/www/html + ErrorLog /var/log/terra + + + RewriteEngine on + + + + # Error handler for Drupal > 4.6.7 + + + SetHandler This_is_a_Drupal_security_line_do_not_remove + + Options None + Options +FollowSymLinks + + # If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + + + diff --git a/docker/drupal/terra-entrypoint.sh b/docker/drupal/terra-entrypoint.sh new file mode 100644 index 0000000..905033a --- /dev/null +++ b/docker/drupal/terra-entrypoint.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +# Save certain environment variables to /etc/apache2/envvars so they are available in Apache2 config. +# To make environment variables available to the site itself, see apache-vhost.conf. +echo "TERRA || Saving to /etc/apache2/envvars from environment variables ..." +echo "export TERRA_ENVIRONMENT_URL=$TERRA_ENVIRONMENT_URL" >> /etc/apache2/envvars + +echo "TERRA || Launching apache2-foreground ..." +sudo apache2-foreground& + +echo "TERRA || Following log /var/log/terra ..." +tail -f /var/log/terra From 8690e870ba2fc59ed71921dc3ccb2c42d01adbd6 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 12:07:13 -0400 Subject: [PATCH 30/68] Refactoring docker-compose generation: - Removing tutum/haproxy. jwilder/nginx-proxy acts as a load balancer. - Removing redundant "links". - Removing HOST_UID/GID environment variables. We will generate in a container, not on entrypoint. - Update to docker-compose v2! --- docker/drupal/apache-vhost.conf | 2 +- src/terra/Factory/EnvironmentFactory.php | 42 +++++++++--------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/docker/drupal/apache-vhost.conf b/docker/drupal/apache-vhost.conf index 654a7ae..907c3b3 100644 --- a/docker/drupal/apache-vhost.conf +++ b/docker/drupal/apache-vhost.conf @@ -1,6 +1,6 @@ - ServerName ${TERRA_ENVIRONMENT_URL} + ServerName ${VIRTUAL_HOSTNAME} DocumentRoot /var/www/html ErrorLog /var/log/terra diff --git a/src/terra/Factory/EnvironmentFactory.php b/src/terra/Factory/EnvironmentFactory.php index 9e52ab9..d08ad09 100644 --- a/src/terra/Factory/EnvironmentFactory.php +++ b/src/terra/Factory/EnvironmentFactory.php @@ -310,38 +310,21 @@ public function getDockerComposeArray() $this->environment->name; $compose = array(); - $compose['load'] = array( - 'image' => 'tutum/haproxy', - 'environment' => array( - 'VIRTUAL_HOST' => $hosts, - ), - 'links' => array( - 'app', - ), - 'expose' => array( - '80/tcp', - ), - 'ports' => array( - '80', - ), - ); $compose['app'] = array( 'image' => 'terra/drupal', 'tty' => true, 'stdin_open' => true, - 'links' => array( - 'database', - ), 'volumes' => array( "{$this->environment->path}:/app:z", + "{$this->environment->path}/{$document_root_relative}:/var/www/html:z", ), 'environment' => array( - 'HOST_UID' => posix_getuid(), - 'HOST_GID' => posix_getgid(), - 'DOCUMENT_ROOT' => $document_root_relative, + 'VIRTUAL_HOST' => $hosts, + 'DOCUMENT_ROOT' => $document_root_relative, + 'VIRTUAL_HOSTNAME' => $this->getUrl(), ), - 'expose' => array( - '80/tcp', + 'ports' => array( + '80', ), ); $compose['database'] = array( @@ -354,6 +337,9 @@ public function getDockerComposeArray() 'MYSQL_USER' => 'drupal', 'MYSQL_PASSWORD' => 'drupal', ), + 'logging' => array( + 'driver' => 'none', + ), ); $compose['drush'] = array( 'image' => 'terra/drush', @@ -427,7 +413,11 @@ public function getDockerComposeArray() $compose[$name]['labels']['io.rancher.container.network'] = 'TRUE'; } - return $compose; + # Output docker-compose v2 yaml. + return array( + 'version' => '2', + 'services' => $compose, + ); } /** @@ -543,13 +533,13 @@ public function scale($scale) } /** - * Get's the exposed port of the load balancer container. + * Get's the exposed port of the app container. * * @return bool|mixed */ public function getPort() { - $process = new Process('docker-compose port load 80', $this->getDockerComposePath()); + $process = new Process('docker-compose port app 80', $this->getDockerComposePath()); $process->run(); if (!$process->isSuccessful()) { return false; From c73462702cd53aef409832120ff6c96ea1d5838b Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 12:52:49 -0400 Subject: [PATCH 31/68] Adding new prepareSystem command to run docker build. --- src/terra/Command/PrepareSystem.php | 79 +++++++++++++++++++++++++++++ src/terra/Console/Application.php | 1 + 2 files changed, 80 insertions(+) create mode 100644 src/terra/Command/PrepareSystem.php diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php new file mode 100644 index 0000000..9fe2f4e --- /dev/null +++ b/src/terra/Command/PrepareSystem.php @@ -0,0 +1,79 @@ +setName('prepare:system') + ->setDescription('Builds app containers for your system and launches URL Proxy, among other things.') + ->addArgument( + 'uid', + InputArgument::OPTIONAL, + 'The UID to use when generating the container users. Defaults to the current user.' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln([ + "First, I need a couple of things:", + " 1. A web container built to match your user, so volume mounts match your control user.", + " 2. A local URL proxy (jwilder/nginx-proxy), so requests to local URLs can resolve to individual containers.", + "" + ]); + + if (!$input->getArgument('uid')) { + $uid = trim(shell_exec('id -u')); + if (empty($uid) || !intval($uid)) { + throw new \Exception("UID not found. The command `id -u` failed and returned `$uid`. Please pass your user's UID as an argument to this command: `terra prepare:system 1100`"); + } + $output->writeln([ + "No UID argument entered, so I looked. Your ID was found to be $uid.", + ]); + } + else { + $uid = $input->getArgument('uid'); + } + + // Build app containers. + $path_to_drupal_docker = realpath(__DIR__ . '/../../../docker/drupal'); + $cmd = "docker build -t terra/drupal:local --build-arg TERRA_UID={$uid} {$path_to_drupal_docker}"; + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("I'd like to run `$cmd` Ok? ", false); + + // If yes, gather the necessary info for creating .terra.yml. + if ($helper->ask($input, $output, $question)) { + + $output->writeln([ + "Great! running...", + ]); + + $process = new Process($cmd); + $process->setTimeout(null); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; + } + }); + } + else { + throw new \Exception("Hmm, sorry then. Terra can't work properly without "); + } + } +} diff --git a/src/terra/Console/Application.php b/src/terra/Console/Application.php index deacce3..b01d729 100644 --- a/src/terra/Console/Application.php +++ b/src/terra/Console/Application.php @@ -69,6 +69,7 @@ protected function getDefaultCommands() $commands[] = new Command\Environment\EnvironmentUpdate(); $commands[] = new Command\Status(); $commands[] = new Command\Queue(); + $commands[] = new Command\PrepareSystem(); return $commands; } From ea7358d04ee37e2ed4a443f0a4e77867fc3c13d7 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 12:53:17 -0400 Subject: [PATCH 32/68] Change default docker compose image to terra/drupal:local --- src/terra/Factory/EnvironmentFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terra/Factory/EnvironmentFactory.php b/src/terra/Factory/EnvironmentFactory.php index d08ad09..6e847b3 100644 --- a/src/terra/Factory/EnvironmentFactory.php +++ b/src/terra/Factory/EnvironmentFactory.php @@ -311,7 +311,7 @@ public function getDockerComposeArray() $compose = array(); $compose['app'] = array( - 'image' => 'terra/drupal', + 'image' => 'terra/drupal:local', 'tty' => true, 'stdin_open' => true, 'volumes' => array( From 20db938ac1d22d1fdb94113727ca13c9d07bbc03 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 13:40:45 -0400 Subject: [PATCH 33/68] Output messages if docker build fails or passes. --- src/terra/Command/PrepareSystem.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 9fe2f4e..bb83e5b 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -71,6 +71,29 @@ protected function execute(InputInterface $input, OutputInterface $output) echo 'DOCKER > '.$buffer; } }); + + if ($process->isSuccessful()) { + + $output->writeln([ + '', + "Ok! Your Docker host now has an image for terra/drupal:local", + "I'll use this image to launch your Drupal environments.", + '', + ]); + } + else { + + $output->writeln([ + "", + "Uh oh! The `docker-build` command failed!", + "The command I tried to run was: ", + "{$cmd}", + "", + "Please check your settings, try to run the command manually, then try again." + ]); + + exit(1); + } } else { throw new \Exception("Hmm, sorry then. Terra can't work properly without "); From d2124693c691b7b0ba13340a436d1111240910c1 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 13:47:43 -0400 Subject: [PATCH 34/68] Add launching of URL proxy container to prepare:system command. --- src/terra/Command/PrepareSystem.php | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index bb83e5b..0888a3a 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -98,5 +98,47 @@ protected function execute(InputInterface $input, OutputInterface $output) else { throw new \Exception("Hmm, sorry then. Terra can't work properly without "); } + + $output->writeln([ + "", + "Next up: URL Proxy. I need to launch a container with jwilder/nging-proxy for this to work.", + "You can review the Docker image here: https://hub.docker.com/r/jwilder/nginx-proxy/", + "", + ]); + + $cmd = 'docker run --name terra-nginx-proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --security-opt label:disable jwilder/nginx-proxy'; + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("I'd like to run `$cmd` Ok? ", false); + + // If yes, gather the necessary info for creating .terra.yml. + if ($helper->ask($input, $output, $question)) { + + $output->writeln([ + "Great! running...", + ]); + + $process = new Process($cmd); + $process->setTimeout(null); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; + } + }); + + if ($process->isSuccessful()) { + + $output->writeln([ + "", + "Ok, that worked! You can now use full domain names to load sites.", + "", + ]); + } + else { + throw new \Exception("Ouch. Something went wrong when running the command. Review and try again."); + } + } } } From 25b8506381dcf46aac28d9225b76bf6179743f62 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:11:10 -0400 Subject: [PATCH 35/68] Add a check for the terra-nginx-proxy container, and offer to kill & remove (if it is found to be running) or just remove it (if it's not running.) --- src/terra/Command/PrepareSystem.php | 80 ++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 0888a3a..8abe91a 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -106,18 +106,86 @@ protected function execute(InputInterface $input, OutputInterface $output) "", ]); + $process = new Process('docker inspect terra-nginx-proxy'); + $process->setTimeout(null); + $process->run(); + if ($process->isSuccessful()) { + + $output->writeln([ + "", + "Wait a minute, it looks like you already have a container 'terra-nginx-proxy',", + ]); + + $process = new Process('docker ps --filter name=terra-nginx-proxy -q'); + $process->run(); + // docker ps with filter outputs empty but OK if there are no containers. + if (!empty($process->getOutput())) { + $output->writeln([ + "and it is running.", + "I can remove it for you by running `$cmd`... We can just launch a new one. ", + ]); + + // Ask to remove it. + $cmd = 'docker kill terra-nginx-proxy; docker rm -fv terra-nginx-proxy'; + $question = new ConfirmationQuestion("Ok? [y/N]", false); + if ($helper->ask($input, $output, $question)) { + $process = new Process($cmd); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; + } + }); + + if (!$process->isSuccessful()) { + $output->writeln([ + "", + "Uh oh! The `docker kill` and `docker rm` commands failed!", + ]); + } + } + } + else { + $output->writeln([ + "but it is not running. Would you like me to remove it before starting a new container?", + ]); + + // Ask to remove it. + $cmd = 'docker rm -fv terra-nginx-proxy'; + $question = new ConfirmationQuestion("Would you like me to stop and remove it by running `$cmd`? We can just launch anotherone next. Ok? ", false); + if ($helper->ask($input, $output, $question)) { + $process = new Process($cmd); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; + } + }); + + if (!$process->isSuccessful()) { + $output->writeln([ + "", + "Uh oh! The `docker kill` and `docker rm` commands failed!", + ]); + } + } + } + } + $cmd = 'docker run --name terra-nginx-proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --security-opt label:disable jwilder/nginx-proxy'; + $output->writeln([ + "I'd like to run `$cmd` " + ]); + $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion("I'd like to run `$cmd` Ok? ", false); + $question = new ConfirmationQuestion("Ok? [Y/n]", false); // If yes, gather the necessary info for creating .terra.yml. if ($helper->ask($input, $output, $question)) { - $output->writeln([ - "Great! running...", - ]); - $process = new Process($cmd); $process->setTimeout(null); $process->run(function ($type, $buffer) { @@ -132,7 +200,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln([ "", - "Ok, that worked! You can now use full domain names to load sites.", + "Ok, that worked! You can now use VIRTUAL_HOST domain names to load sites.", "", ]); } From c8ffe49d7decdd3e05dfd89d5e19ccfc4f4319f8 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:11:46 -0400 Subject: [PATCH 36/68] Add `terra prepare:system -y` to the travis yml file. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c773f1f..3cb0e02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ install: script: - terra - drush + - terra prepare:system -y - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - bin/terra e:a drupal demo demo -n - cat ~/.terra/environments/drupal/drupal-demo/docker-compose.yml From df86de4187992f37a029eb5650990f58196691aa Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:14:38 -0400 Subject: [PATCH 37/68] Better message about UID. --- src/terra/Command/PrepareSystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 8abe91a..6e08e3a 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \Exception("UID not found. The command `id -u` failed and returned `$uid`. Please pass your user's UID as an argument to this command: `terra prepare:system 1100`"); } $output->writeln([ - "No UID argument entered, so I looked. Your ID was found to be $uid.", + "It looks like your UID is $uid.", ]); } else { From cf4203ebcf79e401d06d9b1f0c7b037a5f7a5f07 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:18:25 -0400 Subject: [PATCH 38/68] More description of the VIRTUAL_HOST thing. --- src/terra/Command/PrepareSystem.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 6e08e3a..ece14fd 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -52,15 +52,16 @@ protected function execute(InputInterface $input, OutputInterface $output) $path_to_drupal_docker = realpath(__DIR__ . '/../../../docker/drupal'); $cmd = "docker build -t terra/drupal:local --build-arg TERRA_UID={$uid} {$path_to_drupal_docker}"; + $output->writeln([ + "I'd like to run `$cmd` ..." + ]); + $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion("I'd like to run `$cmd` Ok? ", false); + $question = new ConfirmationQuestion("Ok? [Y/n]", false); // If yes, gather the necessary info for creating .terra.yml. if ($helper->ask($input, $output, $question)) { - $output->writeln([ - "Great! running...", - ]); $process = new Process($cmd); $process->setTimeout(null); @@ -201,6 +202,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln([ "", "Ok, that worked! You can now use VIRTUAL_HOST domain names to load sites.", + "Look for the URL like http://app.environment.local.computer. You can click to access your sites if you are using terra on your local machine.", + "You can also fire up more containers manually with the Environment variable VIRTUAL_HOST=mydomain.local.computer to route requests for that domain to that container.", + "For more information, visit https://github.com/jwilder/nginx-proxy", "", ]); } From e9683422d6bda2095fc505f2b3d9e74bc8827a59 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:20:35 -0400 Subject: [PATCH 39/68] Curl the site, see if we got something. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3cb0e02..a4ec1c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,4 +27,5 @@ script: - bin/terra e:e drupal demo - bin/terra status + - curl http://drupal.demo.local.computer From 515dc6704ff2b4bb85ea1b56d49441f00f4e5e2e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:22:10 -0400 Subject: [PATCH 40/68] Get docker logs in travis test. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a4ec1c5..d22afdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,7 @@ script: - bin/terra e:e drupal demo - bin/terra status + - cd ~/.terra/environments/drupal/drupal-demo/ + - docker-compose logs - curl http://drupal.demo.local.computer From c3936c34d7418e95fc14f398233cddb0f753c318 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:41:50 -0400 Subject: [PATCH 41/68] Add composer to Dockerfile. --- docker/drupal/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 8d35781..82f77e5 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -46,6 +46,15 @@ RUN chgrp $TERRA_USER /var/log/terra COPY terra-entrypoint.sh /usr/local/bin/terra-entrypoint RUN chmod +x /usr/local/bin/terra-entrypoint +# Add composer CLI +# Instructions from from https://getcomposer.org/download/ +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ + php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \ + php composer-setup.php && \ + php -r "unlink('composer-setup.php');" && \ + mv composer.phar /usr/local/bin/composer && \ + chmod +x /usr/local/bin/composer && \ + composer RUN cat /etc/sudoers.d/$TERRA_USER From 4ec691637285009825cf2e01e868b83cb8422a81 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 14:55:51 -0400 Subject: [PATCH 42/68] Adding Drush to Dockerfile. --- docker/drupal/Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 82f77e5..97706eb 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -13,6 +13,9 @@ ARG TERRA_UID=1000 # TERRA_GID will default to TERRA_UID, unless passed as a build-arg to `docker-build`. ARG TERRA_GID=$TERRA_UID +# This will be updated as drush is released. +ARG DRUSH_VERSION=8.1.12 + ENV TERRA_USER=terra ENV TERRA_HOME=/var/terra @@ -56,6 +59,13 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && chmod +x /usr/local/bin/composer && \ composer +# Install Drush. We will handle site-local drush soon. +RUN echo "Installing drush version $DRUSH_VERSION" +RUN curl https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar -L -O -s && \ + mv drush.phar /usr/local/bin/drush && \ + chmod +x /usr/local/bin/drush && \ + drush + RUN cat /etc/sudoers.d/$TERRA_USER USER $TERRA_USER From 4790e57cb857f02d768d8f3c05f6e25753550ef3 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 15:09:40 -0400 Subject: [PATCH 43/68] Add drushrc config in entrypoint since that is when we know the virtualhost name. --- docker/drupal/terra-entrypoint.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker/drupal/terra-entrypoint.sh b/docker/drupal/terra-entrypoint.sh index 905033a..d144a1b 100644 --- a/docker/drupal/terra-entrypoint.sh +++ b/docker/drupal/terra-entrypoint.sh @@ -10,5 +10,15 @@ echo "export TERRA_ENVIRONMENT_URL=$TERRA_ENVIRONMENT_URL" >> /etc/apache2/envva echo "TERRA || Launching apache2-foreground ..." sudo apache2-foreground& +if [ ! -d "$HOME/.drush" ]; then + mkdir "$HOME/.drush" +fi + +echo "TERRA || Writing drushrc.php ..." +echo "> $HOME/.drush/drushrc.php + echo "TERRA || Following log /var/log/terra ..." tail -f /var/log/terra From a05c88b1f5653d492e5beedb8ffce39cad674c28 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 15:11:07 -0400 Subject: [PATCH 44/68] Fixing URI to VIRTUAL_HOSTNAME --- docker/drupal/terra-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/drupal/terra-entrypoint.sh b/docker/drupal/terra-entrypoint.sh index d144a1b..e432c1d 100644 --- a/docker/drupal/terra-entrypoint.sh +++ b/docker/drupal/terra-entrypoint.sh @@ -5,7 +5,7 @@ set -e # Save certain environment variables to /etc/apache2/envvars so they are available in Apache2 config. # To make environment variables available to the site itself, see apache-vhost.conf. echo "TERRA || Saving to /etc/apache2/envvars from environment variables ..." -echo "export TERRA_ENVIRONMENT_URL=$TERRA_ENVIRONMENT_URL" >> /etc/apache2/envvars +echo "export VIRTUAL_HOSTNAME=$VIRTUAL_HOSTNAME" >> /etc/apache2/envvars echo "TERRA || Launching apache2-foreground ..." sudo apache2-foreground& @@ -17,7 +17,7 @@ fi echo "TERRA || Writing drushrc.php ..." echo "> $HOME/.drush/drushrc.php echo "TERRA || Following log /var/log/terra ..." From 59b762eaed969dd97b658156961509531f2f1b76 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 15:34:37 -0400 Subject: [PATCH 45/68] Overwrite drushrc.php in entrypoint. --- docker/drupal/terra-entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/drupal/terra-entrypoint.sh b/docker/drupal/terra-entrypoint.sh index e432c1d..855f45e 100644 --- a/docker/drupal/terra-entrypoint.sh +++ b/docker/drupal/terra-entrypoint.sh @@ -10,6 +10,7 @@ echo "export VIRTUAL_HOSTNAME=$VIRTUAL_HOSTNAME" >> /etc/apache2/envvars echo "TERRA || Launching apache2-foreground ..." sudo apache2-foreground& +echo "TERRA || Writing drushrc.php ..." if [ ! -d "$HOME/.drush" ]; then mkdir "$HOME/.drush" fi @@ -18,7 +19,7 @@ echo "TERRA || Writing drushrc.php ..." echo "> $HOME/.drush/drushrc.php + " > $HOME/.drush/drushrc.php echo "TERRA || Following log /var/log/terra ..." tail -f /var/log/terra From 11d22f2379f04fe8d5879e65f92b3b3328074d29 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 15:42:17 -0400 Subject: [PATCH 46/68] output logs of nginx proxy. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d22afdc..521548a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ script: - terra - drush - terra prepare:system -y + - docker logs terra-nginx-proxy - bin/terra app:add drupal http://github.com/terra-ops/example-drupal.git --description='sample app' --host=local.computer -n - bin/terra e:a drupal demo demo -n - cat ~/.terra/environments/drupal/drupal-demo/docker-compose.yml From 0a0c0512656178bf9f11dd4baf7c0b0a5bdf100e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 16:08:34 -0400 Subject: [PATCH 47/68] Get port of container in order to CURL, until the nginx-proxy starts working again. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 521548a..c76ee9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,5 +30,8 @@ script: - bin/terra status - cd ~/.terra/environments/drupal/drupal-demo/ - docker-compose logs - - curl http://drupal.demo.local.computer + - PORT=`docker inspect --format '{{ (index (index .NetworkSettings.Ports "80/tcp") 0).HostPort }}' drupaldemo_app_1` + - $URL="http://localhost:$PORT" + - echo $URL + - curl $URL From 7ea2332d48e70cf9848cb30f30b1f68d6440b89f Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 30 Jun 2017 16:13:41 -0400 Subject: [PATCH 48/68] Echo Port and assign URL correctly --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c76ee9b..9d02650 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,8 @@ script: - cd ~/.terra/environments/drupal/drupal-demo/ - docker-compose logs - PORT=`docker inspect --format '{{ (index (index .NetworkSettings.Ports "80/tcp") 0).HostPort }}' drupaldemo_app_1` - - $URL="http://localhost:$PORT" + - echo $PORT + - URL="http://localhost:$PORT" - echo $URL - curl $URL From 5796c1535bb757912c61db2cbf28af98d8e704db Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Sat, 1 Jul 2017 07:21:39 -0400 Subject: [PATCH 49/68] Add mysql-client and php5-mysql to Drupal container. --- docker/drupal/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 97706eb..c6f488c 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -23,6 +23,8 @@ ENV TERRA_HOME=/var/terra # @TODO: Add this to a new upstream image. RUN apt-get -qq update && apt-get -qq -y install \ git \ + mysql-client \ + php5-mysql \ sudo \ zip From 4792169ac29167e67d8505e11db592a1f17479e9 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Wed, 30 Aug 2017 07:32:45 -0400 Subject: [PATCH 50/68] Adding site install to travis tests. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9d02650..d37d24e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,7 @@ script: - URL="http://localhost:$PORT" - echo $URL - curl $URL - + - docker-compose exec app drush site-install -y + - curl $URL + - docker-compose exec app drush status + - docker-compose exec app drush uli From afdc4404b1df452a87623998b0b0ab7741e9d5f6 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:27:03 -0400 Subject: [PATCH 51/68] Add nginx network in prepare system command. --- src/terra/Command/PrepareSystem.php | 67 +++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index ece14fd..86a51ed 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -201,10 +201,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln([ "", - "Ok, that worked! You can now use VIRTUAL_HOST domain names to load sites.", - "Look for the URL like http://app.environment.local.computer. You can click to access your sites if you are using terra on your local machine.", - "You can also fire up more containers manually with the Environment variable VIRTUAL_HOST=mydomain.local.computer to route requests for that domain to that container.", - "For more information, visit https://github.com/jwilder/nginx-proxy", + "Ok, that worked! Now you have a container bound to port 80 on your host.", "", ]); } @@ -212,5 +209,67 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \Exception("Ouch. Something went wrong when running the command. Review and try again."); } } + + // ADD NETWORK + $output->writeln([ + "", + "Last step: For the URL Proxy to work, we need to add a docker network called 'terra-nginx-network'.", + "", + ]); + + $process = new Process('docker network inspect terra-nginx-network'); + $process->setTimeout(NULL); + $process->run(); + if ($process->isSuccessful()) { + + $output->writeln([ + "", + "Wait a minute, it looks like you already have a network called 'terra-nginx-network'. You should be good to go!", + ]); + } + else { + + $cmds = []; + $cmds[] = 'docker network create terra-nginx-network'; + $cmds[] = 'docker network connect terra-nginx-network terra-nginx-proxy'; + + $output->writeln([ + "I'd like to run:" + ]); + $output->writeln($cmds); + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("Ok? [Y/n]", FALSE); + if ($helper->ask($input, $output, $question)) { + + foreach ($cmds as $cmd) { + $process = new Process($cmd); + $process->setTimeout(NULL); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > ' . $buffer; + } + else { + echo 'DOCKER > ' . $buffer; + } + }); + + if ($process->isSuccessful()) { + $output->writeln([ + "Command success!", + ]); + } + else { + throw new \Exception("Ouch. Something went wrong when running the command. Review and try again."); + } + } + + } + } + + $output->writeln([ + "", + "You should be good to go! Try `terra app:add` to get started!", + ]); } } From 4f755e84a32176e58d530b15fd9a62c521977878 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:28:45 -0400 Subject: [PATCH 52/68] Cleaner text. --- src/terra/Command/PrepareSystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 86a51ed..7eabfed 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -224,7 +224,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln([ "", - "Wait a minute, it looks like you already have a network called 'terra-nginx-network'. You should be good to go!", + "Wait a minute, it looks like you already have a network called 'terra-nginx-network'.", ]); } else { From 02423648f2021088cf994f605732e1b1e21cd0c6 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:34:45 -0400 Subject: [PATCH 53/68] Put input and output as command class properties. --- src/terra/Command/Command.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/terra/Command/Command.php b/src/terra/Command/Command.php index 007b606..3bb68b5 100644 --- a/src/terra/Command/Command.php +++ b/src/terra/Command/Command.php @@ -18,6 +18,16 @@ class Command extends CommandBase { protected $app; protected $environment; + + /** + * @var InputInterface + */ + protected $input; + + /** + * @var OutputInterface + */ + protected $output; /** * Detect app and environment from current path. @@ -27,6 +37,10 @@ class Command extends CommandBase */ protected function initialize(InputInterface $input, OutputInterface $output) { + // Set Input and output + $this->input = $input; + $this->output = $output; + // Determine app and environment from path. $cwd = getcwd(); $config = $this->getApplication()->getTerra()->getConfig(); @@ -199,4 +213,11 @@ public function getEnvironmentFactory() { return new EnvironmentFactory($this->environment, $this->app); } + + /** + * Confirm with the user, then Run a process and output the results. + */ + public function exec($cmd) { + + } } From 393255cc95b9edad6ee5e34d220f1e91573de857 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:51:26 -0400 Subject: [PATCH 54/68] Removing code that asks the user to remove the proxy container then restart it, separate adding container to network. --- src/terra/Command/PrepareSystem.php | 177 +++++++++++----------------- 1 file changed, 70 insertions(+), 107 deletions(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index 7eabfed..a0336da 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -62,7 +62,6 @@ protected function execute(InputInterface $input, OutputInterface $output) // If yes, gather the necessary info for creating .terra.yml. if ($helper->ask($input, $output, $question)) { - $process = new Process($cmd); $process->setTimeout(null); $process->run(function ($type, $buffer) { @@ -81,25 +80,23 @@ protected function execute(InputInterface $input, OutputInterface $output) "I'll use this image to launch your Drupal environments.", '', ]); - } - else { + } + else { - $output->writeln([ - "", - "Uh oh! The `docker-build` command failed!", - "The command I tried to run was: ", - "{$cmd}", - "", - "Please check your settings, try to run the command manually, then try again." - ]); + $output->writeln([ + "", + "Uh oh! The `docker-build` command failed!", + "The command I tried to run was: ", + "{$cmd}", + "", + "Please check your settings, try to run the command manually, then try again." + ]); - exit(1); - } + exit(1); } - else { - throw new \Exception("Hmm, sorry then. Terra can't work properly without "); } - + + $output->writeln([ "", "Next up: URL Proxy. I need to launch a container with jwilder/nging-proxy for this to work.", @@ -114,99 +111,43 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln([ "", - "Wait a minute, it looks like you already have a container 'terra-nginx-proxy',", + "Wait a minute, it looks like you already have a container 'terra-nginx-proxy'. You should be good to go.", ]); - - $process = new Process('docker ps --filter name=terra-nginx-proxy -q'); - $process->run(); - // docker ps with filter outputs empty but OK if there are no containers. - if (!empty($process->getOutput())) { - $output->writeln([ - "and it is running.", - "I can remove it for you by running `$cmd`... We can just launch a new one. ", - ]); - - // Ask to remove it. - $cmd = 'docker kill terra-nginx-proxy; docker rm -fv terra-nginx-proxy'; - $question = new ConfirmationQuestion("Ok? [y/N]", false); - if ($helper->ask($input, $output, $question)) { - $process = new Process($cmd); - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'DOCKER > '.$buffer; - } else { - echo 'DOCKER > '.$buffer; - } - }); - - if (!$process->isSuccessful()) { - $output->writeln([ - "", - "Uh oh! The `docker kill` and `docker rm` commands failed!", - ]); - } - } - } - else { - $output->writeln([ - "but it is not running. Would you like me to remove it before starting a new container?", - ]); - - // Ask to remove it. - $cmd = 'docker rm -fv terra-nginx-proxy'; - $question = new ConfirmationQuestion("Would you like me to stop and remove it by running `$cmd`? We can just launch anotherone next. Ok? ", false); - if ($helper->ask($input, $output, $question)) { - $process = new Process($cmd); - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'DOCKER > '.$buffer; - } else { - echo 'DOCKER > '.$buffer; - } - }); - - if (!$process->isSuccessful()) { - $output->writeln([ - "", - "Uh oh! The `docker kill` and `docker rm` commands failed!", - ]); + } + else { + $cmd = 'docker run --name terra-nginx-proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --security-opt label:disable jwilder/nginx-proxy'; + + $output->writeln([ + "I'd like to run `$cmd` " + ]); + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("Ok? [Y/n]", false); + + // If yes, gather the necessary info for creating .terra.yml. + if ($helper->ask($input, $output, $question)) { + + $process = new Process($cmd); + $process->setTimeout(null); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; } + }); + + if ($process->isSuccessful()) { + + $output->writeln([ + "", + "Ok, that worked! Now you have a container bound to port 80 on your host.", + "", + ]); } - } - } - - $cmd = 'docker run --name terra-nginx-proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --security-opt label:disable jwilder/nginx-proxy'; - - $output->writeln([ - "I'd like to run `$cmd` " - ]); - - $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion("Ok? [Y/n]", false); - - // If yes, gather the necessary info for creating .terra.yml. - if ($helper->ask($input, $output, $question)) { - - $process = new Process($cmd); - $process->setTimeout(null); - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'DOCKER > '.$buffer; - } else { - echo 'DOCKER > '.$buffer; + else { + throw new \Exception("Ouch. Something went wrong when running the command. Review and try again."); } - }); - - if ($process->isSuccessful()) { - - $output->writeln([ - "", - "Ok, that worked! Now you have a container bound to port 80 on your host.", - "", - ]); - } - else { - throw new \Exception("Ouch. Something went wrong when running the command. Review and try again."); } } @@ -231,7 +172,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $cmds = []; $cmds[] = 'docker network create terra-nginx-network'; - $cmds[] = 'docker network connect terra-nginx-network terra-nginx-proxy'; $output->writeln([ "I'd like to run:" @@ -256,7 +196,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($process->isSuccessful()) { $output->writeln([ - "Command success!", + "Great! The network was created.", ]); } else { @@ -266,6 +206,29 @@ protected function execute(InputInterface $input, OutputInterface $output) } } + + // Attach containers + $cmd = 'docker network connect terra-nginx-network terra-nginx-proxy'; + + $output->writeln([ + "I'd like to run: " . $cmd + ]); + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("Ok? [Y/n]", FALSE); + if ($helper->ask($input, $output, $question)) { + + $process = new Process($cmd); + $process->setTimeout(NULL); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > ' . $buffer; + } + else { + echo 'DOCKER > ' . $buffer; + } + }); + } $output->writeln([ "", From c4f1c252f4465cbad5d84b7dbea1b48899baf538 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:54:59 -0400 Subject: [PATCH 55/68] Removing "url proxy" command in favor of prepare system. --- .../Command/Environment/EnvironmentEnable.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/terra/Command/Environment/EnvironmentEnable.php b/src/terra/Command/Environment/EnvironmentEnable.php index 15e34e6..8c2b82b 100644 --- a/src/terra/Command/Environment/EnvironmentEnable.php +++ b/src/terra/Command/Environment/EnvironmentEnable.php @@ -116,26 +116,22 @@ protected function execute(InputInterface $input, OutputInterface $output) */ protected function ensureProxy(InputInterface $input, OutputInterface $output) { - // Get running containers. - $cmd = 'docker ps'; + // Lookup info on terra-nginx-proxy + $cmd = 'docker inspect terra-nginx-proxy'; $process = new Process($cmd); $process->run(); - if (!$process->isSuccessful()) { - throw new ProcessFailedException($process); - } - // Look for running instance of URL proxy in `docker ps` output. - if (!strpos($process->getOutput(), 'jwilder/nginx-proxy')) { + if (!$process->isSuccessful()) { // If there's no running instance, offer to create one $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("URL proxy is not running, would you like to enable it now? [Y/n] ", true); if (!$helper->ask($input, $output, $question)) { $output->writeln('Cancelled'); } else { - $output->writeln('Starting URL proxy...'); - $command = $this->getApplication()->find('url-proxy:enable'); - $proxyInput = new StringInput('url-proxy:enable'); + $output->writeln('Running command `terra prepare:system...'); + $command = $this->getApplication()->find('prepare:system'); + $proxyInput = new StringInput('prepare:system'); $command->run($proxyInput, $output); } } From 7f32dea58b022eba82b1837137ba0caf5a89eec8 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:55:13 -0400 Subject: [PATCH 56/68] Removing url proxy command. --- src/terra/Console/Application.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/terra/Console/Application.php b/src/terra/Console/Application.php index df562ec..3e8f090 100644 --- a/src/terra/Console/Application.php +++ b/src/terra/Console/Application.php @@ -61,7 +61,6 @@ protected function getDefaultCommands() $commands[] = new Command\Environment\EnvironmentDeploy(); $commands[] = new Command\Environment\EnvironmentShell(); $commands[] = new Command\Environment\EnvironmentScale(); - $commands[] = new Command\Environment\EnvironmentProxyEnable(); $commands[] = new Command\Environment\EnvironmentTest(); $commands[] = new Command\Environment\EnvironmentRebuild(); $commands[] = new Command\Environment\EnvironmentDomains(); From f2452fb7035375779c1ec2829100bea041820aa4 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 11:55:35 -0400 Subject: [PATCH 57/68] Removing URL proxy command in favor of prepare:system command. --- .../Environment/EnvironmentProxyEnable.php | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 src/terra/Command/Environment/EnvironmentProxyEnable.php diff --git a/src/terra/Command/Environment/EnvironmentProxyEnable.php b/src/terra/Command/Environment/EnvironmentProxyEnable.php deleted file mode 100644 index 0e0ee7e..0000000 --- a/src/terra/Command/Environment/EnvironmentProxyEnable.php +++ /dev/null @@ -1,35 +0,0 @@ -setName('url-proxy:enable') - ->setDescription('Enable the URL proxy allowing multiple domains') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $output->writeln('Hello Terra!'); - $cmd = 'docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --security-opt label:disable jwilder/nginx-proxy'; - - $process = new Process($cmd); - $process->setTimeout(null); - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo 'DOCKER > '.$buffer; - } else { - echo 'DOCKER > '.$buffer; - } - }); - } -} From e17da160d39d9390bd9eb5f14e089dffb36c6cd1 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 12:43:50 -0400 Subject: [PATCH 58/68] Adding drush container Dockerfile and entrypoint script to terra-cli repo. --- docker/drush/Dockerfile | 32 +++++++++++++++++++++++++++++++ docker/drush/docker-entrypoint.sh | 26 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 docker/drush/Dockerfile create mode 100644 docker/drush/docker-entrypoint.sh diff --git a/docker/drush/Dockerfile b/docker/drush/Dockerfile new file mode 100644 index 0000000..023cb60 --- /dev/null +++ b/docker/drush/Dockerfile @@ -0,0 +1,32 @@ +FROM drush/drush:8 + +ENV HOST_UID 1000 +ENV HOST_GID 1000 + +#RUN adduser drush --gecos "" --home /home/drush --disabled-password +RUN ln -s /usr/local/src/drush7/drush /usr/bin/drush +RUN apt-get update && apt-get install openssh-server mysql-client php5-mysql -y +RUN drush dl registry_rebuild-7.x +RUN drush cc drush + +RUN mkdir /var/run/sshd +#RUN mkdir /home/drush/.ssh +#RUN mkdir /home/drush/.drush +#RUN chown drush:drush /home/drush/.ssh +#RUN chown drush:drush /home/drush/.drush -R + +RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config + +# SSH login fix. Otherwise user is kicked off after login +RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd + +ENV NOTVISIBLE "in users profile" +RUN echo "export VISIBLE=now" >> /etc/profile + +EXPOSE 22 + +ENTRYPOINT ["docker-entrypoint.sh"] +WORKDIR /source + +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh diff --git a/docker/drush/docker-entrypoint.sh b/docker/drush/docker-entrypoint.sh new file mode 100644 index 0000000..2a9b09c --- /dev/null +++ b/docker/drush/docker-entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -ex + +if [ ! `id -u drush` ]; then + # Create app user + addgroup --gid $HOST_GID drush + + echo $HOST_UID + echo $HOST_GID + + adduser --uid $HOST_UID --gid $HOST_GID --system --disabled-password --home /home/drush drush + + mkdir /home/drush/.ssh + mkdir /home/drush/.drush + + echo $AUTHORIZED_KEYS > /home/drush/.ssh/authorized_keys + + chown drush:drush /home/drush/.ssh -R + chown drush:drush /home/drush/.drush -R + + ln -s /var/www/html /home/drush/html + ln -s /app /home/drush/app +fi + + +/usr/sbin/sshd -D \ No newline at end of file From 6ab6782458d30accad60d2d1c9b5fc609f74a7c9 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 13:12:10 -0400 Subject: [PATCH 59/68] Make sure to set shell of drush user. --- docker/drush/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/drush/docker-entrypoint.sh b/docker/drush/docker-entrypoint.sh index 2a9b09c..692febf 100644 --- a/docker/drush/docker-entrypoint.sh +++ b/docker/drush/docker-entrypoint.sh @@ -8,7 +8,7 @@ if [ ! `id -u drush` ]; then echo $HOST_UID echo $HOST_GID - adduser --uid $HOST_UID --gid $HOST_GID --system --disabled-password --home /home/drush drush + adduser --uid $HOST_UID --gid $HOST_GID --system --shell /bin/bash --disabled-password --home /home/drush drush mkdir /home/drush/.ssh mkdir /home/drush/.drush From 48bbdc4ec8e60eb341b457f9510964181921c9a1 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 13:13:22 -0400 Subject: [PATCH 60/68] Build a terra/drush:local container in the 'prepare:system' command. --- src/terra/Command/PrepareSystem.php | 46 ++++++++++++++++++++++++ src/terra/Factory/EnvironmentFactory.php | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/terra/Command/PrepareSystem.php b/src/terra/Command/PrepareSystem.php index a0336da..841f513 100644 --- a/src/terra/Command/PrepareSystem.php +++ b/src/terra/Command/PrepareSystem.php @@ -96,6 +96,52 @@ protected function execute(InputInterface $input, OutputInterface $output) } } + $path_to_drupal_docker = realpath(__DIR__ . '/../../../docker/drush'); + $cmd = "docker build -t terra/drush:local {$path_to_drupal_docker}"; + + $output->writeln([ + "I'd like to run `$cmd` ..." + ]); + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion("Ok? [Y/n]", false); + + // If yes, gather the necessary info for creating .terra.yml. + if ($helper->ask($input, $output, $question)) { + + $process = new Process($cmd); + $process->setTimeout(null); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo 'DOCKER > '.$buffer; + } else { + echo 'DOCKER > '.$buffer; + } + }); + + if ($process->isSuccessful()) { + + $output->writeln([ + '', + "Ok! Your Docker host now has an image for terra/drupal:local", + "I'll use this image to launch your Drupal environments.", + '', + ]); + } + else { + + $output->writeln([ + "", + "Uh oh! The `docker-build` command failed!", + "The command I tried to run was: ", + "{$cmd}", + "", + "Please check your settings, try to run the command manually, then try again." + ]); + + exit(1); + } + } $output->writeln([ "", diff --git a/src/terra/Factory/EnvironmentFactory.php b/src/terra/Factory/EnvironmentFactory.php index 272ad6a..f938db4 100644 --- a/src/terra/Factory/EnvironmentFactory.php +++ b/src/terra/Factory/EnvironmentFactory.php @@ -342,7 +342,7 @@ public function getDockerComposeArray() ), ); $compose['drush'] = array( - 'image' => 'terra/drush', + 'image' => 'terra/drush:local', 'tty' => true, 'stdin_open' => true, 'links' => array( From aeedcf61e18e02cdf09779b54dcd9baca90d0a1c Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 13:23:48 -0400 Subject: [PATCH 61/68] Set a nice hostname for the containers. --- src/terra/Factory/EnvironmentFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/terra/Factory/EnvironmentFactory.php b/src/terra/Factory/EnvironmentFactory.php index f938db4..346709b 100644 --- a/src/terra/Factory/EnvironmentFactory.php +++ b/src/terra/Factory/EnvironmentFactory.php @@ -312,6 +312,7 @@ public function getDockerComposeArray() $compose = array(); $compose['app'] = array( 'image' => 'terra/drupal:local', + 'hostname' => $this->app->name . '_' . $this->environment->name . '.app', 'tty' => true, 'stdin_open' => true, 'volumes' => array( @@ -343,6 +344,7 @@ public function getDockerComposeArray() ); $compose['drush'] = array( 'image' => 'terra/drush:local', + 'hostname' => $this->app->name . '_' . $this->environment->name . '.drush', 'tty' => true, 'stdin_open' => true, 'links' => array( @@ -623,7 +625,7 @@ public function writeDrushAlias() $drush_alias_file[] = " 'uri' => '{$factory->getHost()}:{$factory->getPort()}',"; $drush_alias_file[] = " 'root' => '$path',"; $drush_alias_file[] = " 'remote-host' => '{$factory->getHost()}',"; - $drush_alias_file[] = " 'remote-user' => 'terra',"; + $drush_alias_file[] = " 'remote-user' => 'drush',"; $drush_alias_file[] = " 'ssh-options' => '-p {$factory->getDrushPort()}',"; $drush_alias_file[] = ');'; } From deb1c4bfbecb8301d450a2a87a1e5e58ad314479 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 31 Aug 2017 13:50:53 -0400 Subject: [PATCH 62/68] Let's play it safe and use php5 for now. --- docker/drupal/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index c6f488c..2329a68 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -1,5 +1,5 @@ # Officially maintained by Docker. -FROM drupal:7-apache +FROM drupal:5-apache # terra/drupal (this file) maintained by THINKDROP MAINTAINER Jon Pugh From 8031eeada7b48cc05e0359cb5a536c388fc32847 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Mon, 16 Oct 2017 11:13:53 -0400 Subject: [PATCH 63/68] Improve composer installation method based on https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md --- docker/drupal/Dockerfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 2329a68..f30b4c2 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -1,5 +1,15 @@ # Officially maintained by Docker. -FROM drupal:5-apache +# FROM drupal:7-apache-php5 + +# @TODO: Remove this block once we can use FROM drupal:7-apache-php5 +# BEGIN Dockerfile for drupal:7-apache-php5 +FROM php:5.5-apache +RUN a2enmod rewrite +RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev \ + && rm -rf /var/lib/apt/lists/* \ + && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ + && docker-php-ext-install gd mbstring pdo pdo_mysql pdo_pgsql +# END Dockerfile for drupal:7-apache-php5 # terra/drupal (this file) maintained by THINKDROP MAINTAINER Jon Pugh @@ -26,6 +36,7 @@ RUN apt-get -qq update && apt-get -qq -y install \ mysql-client \ php5-mysql \ sudo \ + wget \ zip RUN echo "Creating user $TERRA_USER with UID $TERRA_UID and GID $TERRA_GID and HOME of $TERRA_HOME" @@ -52,14 +63,12 @@ COPY terra-entrypoint.sh /usr/local/bin/terra-entrypoint RUN chmod +x /usr/local/bin/terra-entrypoint # Add composer CLI -# Instructions from from https://getcomposer.org/download/ -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ - php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \ - php composer-setup.php && \ - php -r "unlink('composer-setup.php');" && \ +# Instructions from from https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md +# Get SHA from new releases from https://github.com/composer/getcomposer.org/commits/master +RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/4449596339f6ee0b9bbe21117eb7998fd46fbd25/web/installer -O - -q | php -- --quiet && \ mv composer.phar /usr/local/bin/composer && \ chmod +x /usr/local/bin/composer && \ - composer + sudo -u terra composer # Install Drush. We will handle site-local drush soon. RUN echo "Installing drush version $DRUSH_VERSION" From 34b265ed48f701603686805b218ecf98b118fc2e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Mon, 16 Oct 2017 11:25:43 -0400 Subject: [PATCH 64/68] bump to php 5.6 --- docker/drupal/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index f30b4c2..a0cdd78 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -3,7 +3,7 @@ # @TODO: Remove this block once we can use FROM drupal:7-apache-php5 # BEGIN Dockerfile for drupal:7-apache-php5 -FROM php:5.5-apache +FROM php:5.6-apache RUN a2enmod rewrite RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev \ && rm -rf /var/lib/apt/lists/* \ From f14d13bd7ac33f77e4cabf67cbd87d3cf3b57a70 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Mon, 16 Oct 2017 13:57:30 -0400 Subject: [PATCH 65/68] Add bcmath extension to default container. --- docker/drupal/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index a0cdd78..a1259ed 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -8,7 +8,7 @@ RUN a2enmod rewrite RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-install gd mbstring pdo pdo_mysql pdo_pgsql + && docker-php-ext-install gd mbstring pdo pdo_mysql pdo_pgsql bcmath # END Dockerfile for drupal:7-apache-php5 # terra/drupal (this file) maintained by THINKDROP From 4ee5a49d40b4a26bedf0fb88bc78ca1cc4f27907 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Mon, 16 Oct 2017 15:09:18 -0400 Subject: [PATCH 66/68] include ZIP extension. --- docker/drupal/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index a1259ed..73326b5 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -8,7 +8,7 @@ RUN a2enmod rewrite RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-install gd mbstring pdo pdo_mysql pdo_pgsql bcmath + && docker-php-ext-install gd mbstring pdo pdo_mysql pdo_pgsql bcmath zip # END Dockerfile for drupal:7-apache-php5 # terra/drupal (this file) maintained by THINKDROP From b18b250fd2237ae5d939946e90bedc58f62091e8 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Fri, 27 Oct 2017 15:14:10 -0400 Subject: [PATCH 67/68] Add --user option to terra e:sh command. --- src/terra/Command/Environment/EnvironmentShell.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/terra/Command/Environment/EnvironmentShell.php b/src/terra/Command/Environment/EnvironmentShell.php index 2895d60..e344fe2 100644 --- a/src/terra/Command/Environment/EnvironmentShell.php +++ b/src/terra/Command/Environment/EnvironmentShell.php @@ -4,6 +4,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use terra\Command\Command; @@ -30,6 +31,13 @@ protected function configure() 'The service to enter into. Default: app', 'app' ) + ->addOption( + 'user', + 'u', + InputOption::VALUE_OPTIONAL, + 'The user to enter into. Default: terra', + 'terra' + ) ; } @@ -39,7 +47,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->getEnvironment($input, $output); $dir = $this->getEnvironmentFactory()->getDockerComposePath(); $service = $input->getArgument('service'); - $cmd = "docker-compose exec $service bash"; + $user = $input->getOption('user'); + $cmd = "docker-compose exec --user $user $service bash"; $output->writeln("Running '$cmd' in $dir"); $process = new \Symfony\Component\Process\Process($cmd); From 88c232c8c8d96567659f1c485647e5fe29189f2e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Tue, 31 Oct 2017 10:55:51 -0400 Subject: [PATCH 68/68] Add a default php.ini and copy it into the terra/drupal container. --- docker/drupal/Dockerfile | 3 +++ docker/drupal/php.ini | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 docker/drupal/php.ini diff --git a/docker/drupal/Dockerfile b/docker/drupal/Dockerfile index 73326b5..d2e66d3 100644 --- a/docker/drupal/Dockerfile +++ b/docker/drupal/Dockerfile @@ -85,5 +85,8 @@ VOLUME $TERRA_HOME VOLUME /var/www/html/ EXPOSE 80 +# Extra PHP Configurations +COPY php.ini /usr/local/etc/php/ + # Default for drupal:7-apache is apache2-foreground. We want to run as Terra user so we use sudo. CMD ["/usr/local/bin/terra-entrypoint"] \ No newline at end of file diff --git a/docker/drupal/php.ini b/docker/drupal/php.ini new file mode 100644 index 0000000..d0bd81c --- /dev/null +++ b/docker/drupal/php.ini @@ -0,0 +1,2 @@ +date.timezone="America/New_York" +memory_limit="256M" \ No newline at end of file