From b1bd59f19ff98935f0209251c2c366c056f3cdfa Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Sat, 23 Feb 2019 20:12:52 +0000 Subject: [PATCH 1/2] Misc: Fixed bug with dotenv and made some updates to install --- src/Console/InstallArc.php | 103 ++------------- .../etc/confd/templates/env/dotenv.tmpl | 118 +++++++++--------- tools/docker/usr/local/share/env/20-arc-env | 13 ++ 3 files changed, 79 insertions(+), 155 deletions(-) diff --git a/src/Console/InstallArc.php b/src/Console/InstallArc.php index 9cae3e3..f2a161d 100644 --- a/src/Console/InstallArc.php +++ b/src/Console/InstallArc.php @@ -7,14 +7,6 @@ class InstallArc extends Command { - const PACKAGES = [ - 'barryvdh/laravel-ide-helper' => 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - 'ellipsesynergie/api-response' => '', - 'genealabs/laravel-model-caching' => '', - 'lord/laroute' => 'Lord\Laroute\LarouteServiceProvider', - 'laravel/horizon' => 'Laravel\Horizon\HorizonServiceProvider', - ]; - /** * The name and signature of the console command. * @@ -27,7 +19,7 @@ class InstallArc extends Command * * @var string */ - protected $description = 'Install Arc package dependencies'; + protected $description = 'Install Arc'; /** * Execute the console command. @@ -36,45 +28,18 @@ class InstallArc extends Command */ public function handle() { - $this->info('The following packages are suggested as development aids. Arc can install and configure these for you.'); - - $questions = $this->verifyPackageInstalls(); - $this->disaplyConfirmation($questions); + $this->info('Configuring your project...'); - if ($questions) { - $this->info('Installing...'); - $this->runComposerInstall($this->getComposerCommand($questions)); - } + $this->publishConfigs(); - $this->publishConfigs($questions); - $this->configureEnv($questions); - } - - /** - * @param $questions - * @return string - */ - private function getComposerCommand($questions): string - { - $composer = 'composer require '; - $cmd = ''; - foreach ($questions as $question) { - if (strtolower($question['status']) === 'install') { - $cmd .= $question['package'] . ' '; - } - } - - if (!empty($cmd)) { - return $composer.$cmd; - } - - return ''; + $this->info('Cleaning up and removing Arc...'); + $this->runComposer( 'composer remove richdynamix/arc'); } /** * @param $cmd */ - private function runComposerInstall($cmd): void + private function runComposer($cmd): void { if ($cmd) { $process = new Process($cmd, null, array_merge($_SERVER, $_ENV), null, null); @@ -84,63 +49,9 @@ private function runComposerInstall($cmd): void } } - /** - * @return array - */ - private function verifyPackageInstalls(): array - { - $questions = []; - $item = 0; - foreach (self::PACKAGES as $package => $provider) { - $questions[$item]['package'] = $package; - $questions[$item]['provider'] = $provider; - $status = $this->confirm("Would you like to install $package?") ? 'Install' : 'Not Installed'; - $questions[$item]['status'] = $status; - ++$item; - } - return $questions; - } - - /** - * @param $questions - */ - private function disaplyConfirmation($questions): void - { - $headers = ['Package', 'Provider', 'Status']; - $this->table($headers, $questions); - } - - /** - * @param $questions - */ - private function publishConfigs($questions): void + private function publishConfigs(): void { $this->info('Publishing Config...'); $this->call('vendor:publish', ['--provider' => 'Richdynamix\Arc\ArcServiceProvider']); - - foreach ($questions as $question) { - if ($question['provider']) { - $this->call('vendor:publish', ['--provider' => $question['provider']]); - } - } - } - - private function configureEnv($questions) - { - $packages = collect($questions); - $env = file_get_contents(base_path('tools/docker/usr/local/share/env/20-arc-env')); - - $horizon = $packages->where('package', 'laravel/horizon')->first(); - if ($horizon['status'] === 'Install') { - $oldHorizonConfig = 'START_HORIZON=${START_HORIZON:-false}'; - $newHorizonConfig = 'START_HORIZON=${START_HORIZON:-true}'; - $newEnv = str_replace($oldHorizonConfig, $newHorizonConfig, $env); - - $oldQueueConfig = 'START_QUEUE=${START_QUEUE:-true}'; - $newQueueConfig = 'START_QUEUE=${START_QUEUE:-false}'; - $newEnv = str_replace($oldQueueConfig, $newQueueConfig, $newEnv); - - file_put_contents(base_path('tools/docker/usr/local/share/env/20-arc-env'), $newEnv); - } } } diff --git a/tools/docker/etc/confd/templates/env/dotenv.tmpl b/tools/docker/etc/confd/templates/env/dotenv.tmpl index 2db5421..66c33c6 100755 --- a/tools/docker/etc/confd/templates/env/dotenv.tmpl +++ b/tools/docker/etc/confd/templates/env/dotenv.tmpl @@ -1,59 +1,59 @@ -APP_NAME="{{ getenv "APP_NAME" }}"; -APP_ENV="{{ getenv "APP_ENV" }}"; -APP_KEY="{{ getenv "APP_KEY" }}"; -APP_DEBUG="{{ getenv "APP_DEBUG" }}"; -LOG_CHANNEL="{{ getenv "LOG_CHANNEL" }}"; -APP_URL="{{ getenv "APP_URL" }}"; - -DB_CONNECTION="{{ getenv "DB_CONNECTION" }}"; -DB_HOST="{{ getenv "DB_HOST" }}"; -DB_PORT="{{ getenv "DB_PORT" }}"; -DB_DATABASE="{{ getenv "DB_DATABASE" }}"; -DB_USERNAME="{{ getenv "DB_USERNAME" }}"; -DB_PASSWORD="{{ getenv "DB_PASSWORD" }}"; - -MAIL_DRIVER="{{ getenv "MAIL_DRIVER" }}"; -MAIL_HOST="{{ getenv "MAIL_HOST" }}"; -MAIL_PORT="{{ getenv "MAIL_PORT" }}"; -MAIL_USERNAME="{{ getenv "MAIL_USERNAME" }}"; -MAIL_PASSWORD="{{ getenv "MAIL_PASSWORD" }}"; -MAIL_ENCRYPTION="{{ getenv "MAIL_ENCRYPTION" }}"; - -CACHE_DRIVER="{{ getenv "CACHE_DRIVER" }}"; -SESSION_DRIVER="{{ getenv "SESSION_DRIVER" }}"; -QUEUE_DRIVER="{{ getenv "QUEUE_DRIVER" }}"; -SESSION_DRIVER="{{ getenv "SESSION_DRIVER" }}"; -SESSION_LIFETIME="{{ getenv "SESSION_LIFETIME" }}"; - -REDIS_HOST="{{ getenv "REDIS_HOST" }}"; -REDIS_PASSWORD="{{ getenv "REDIS_PASSWORD" }}"; -REDIS_PORT="{{ getenv "REDIS_PORT" }}"; - -MIX_PUSHER_APP_KEY="{{ getenv "MIX_PUSHER_APP_KEY" }}"; -MIX_PUSHER_APP_CLUSTER="{{ getenv "MIX_PUSHER_APP_CLUSTER" }}"; - -AUTHY_SECRET="{{ getenv "AUTHY_SECRET" }}"; - -STRIPE_MODEL="{{ getenv "STRIPE_MODEL" }}"; -STRIPE_KEY="{{ getenv "STRIPE_KEY" }}"; -STRIPE_SECRET="{{ getenv "STRIPE_SECRET" }}"; - -BRAINTREE_MODEL="{{ getenv "BRAINTREE_MODEL" }}"; -BRAINTREE_ENV="{{ getenv "BRAINTREE_ENV" }}"; -BRAINTREE_MERCHANT_ID="{{ getenv "BRAINTREE_MERCHANT_ID" }}"; -BRAINTREE_PUBLIC_KEY="{{ getenv "BRAINTREE_PUBLIC_KEY" }}"; -BRAINTREE_PRIVATE_KEY="{{ getenv "BRAINTREE_PRIVATE_KEY" }}"; - -BROADCAST_DRIVER="{{ getenv "BROADCAST_DRIVER" }}"; -PUSHER_APP_ID="{{ getenv "PUSHER_APP_ID" }}"; -PUSHER_KEY="{{ getenv "PUSHER_KEY" }}"; -PUSHER_SECRET="{{ getenv "PUSHER_SECRET" }}"; -PUSHER_APP_CLUSTER="{{ getenv "PUSHER_APP_CLUSTER" }}"; - -SENTRY_DSN="{{ getenv "SENTRY_DSN" }}"; -LOGGLY_TOKEN="{{ getenv "LOGGLY_TOKEN" }}"; - -AWS_ACCESS_KEY_ID="{{ getenv "AWS_ACCESS_KEY_ID" }}"; -AWS_SECRET_ACCESS_KEY="{{ getenv "AWS_SECRET_ACCESS_KEY" }}"; -AWS_DEFAULT_REGION="{{ getenv "AWS_DEFAULT_REGION" }}"; -AWS_BUCKET="{{ getenv "AWS_BUCKET" }}"; \ No newline at end of file +APP_NAME="{{ getenv "APP_NAME" }}" +APP_ENV="{{ getenv "APP_ENV" }}" +APP_KEY="{{ getenv "APP_KEY" }}" +APP_DEBUG="{{ getenv "APP_DEBUG" }}" +LOG_CHANNEL="{{ getenv "LOG_CHANNEL" }}" +APP_URL="{{ getenv "APP_URL" }}" + +DB_CONNECTION="{{ getenv "DB_CONNECTION" }}" +DB_HOST="{{ getenv "DB_HOST" }}" +DB_PORT="{{ getenv "DB_PORT" }}" +DB_DATABASE="{{ getenv "DB_DATABASE" }}" +DB_USERNAME="{{ getenv "DB_USERNAME" }}" +DB_PASSWORD="{{ getenv "DB_PASSWORD" }}" + +MAIL_DRIVER="{{ getenv "MAIL_DRIVER" }}" +MAIL_HOST="{{ getenv "MAIL_HOST" }}" +MAIL_PORT="{{ getenv "MAIL_PORT" }}" +MAIL_USERNAME="{{ getenv "MAIL_USERNAME" }}" +MAIL_PASSWORD="{{ getenv "MAIL_PASSWORD" }}" +MAIL_ENCRYPTION="{{ getenv "MAIL_ENCRYPTION" }}" + +CACHE_DRIVER="{{ getenv "CACHE_DRIVER" }}" +SESSION_DRIVER="{{ getenv "SESSION_DRIVER" }}" +QUEUE_DRIVER="{{ getenv "QUEUE_DRIVER" }}" +SESSION_DRIVER="{{ getenv "SESSION_DRIVER" }}" +SESSION_LIFETIME="{{ getenv "SESSION_LIFETIME" }}" + +REDIS_HOST="{{ getenv "REDIS_HOST" }}" +REDIS_PASSWORD="{{ getenv "REDIS_PASSWORD" }}" +REDIS_PORT="{{ getenv "REDIS_PORT" }}" + +MIX_PUSHER_APP_KEY="{{ getenv "MIX_PUSHER_APP_KEY" }}" +MIX_PUSHER_APP_CLUSTER="{{ getenv "MIX_PUSHER_APP_CLUSTER" }}" + +AUTHY_SECRET="{{ getenv "AUTHY_SECRET" }}" + +STRIPE_MODEL="{{ getenv "STRIPE_MODEL" }}" +STRIPE_KEY="{{ getenv "STRIPE_KEY" }}" +STRIPE_SECRET="{{ getenv "STRIPE_SECRET" }}" + +BRAINTREE_MODEL="{{ getenv "BRAINTREE_MODEL" }}" +BRAINTREE_ENV="{{ getenv "BRAINTREE_ENV" }}" +BRAINTREE_MERCHANT_ID="{{ getenv "BRAINTREE_MERCHANT_ID" }}" +BRAINTREE_PUBLIC_KEY="{{ getenv "BRAINTREE_PUBLIC_KEY" }}" +BRAINTREE_PRIVATE_KEY="{{ getenv "BRAINTREE_PRIVATE_KEY" }}" + +BROADCAST_DRIVER="{{ getenv "BROADCAST_DRIVER" }}" +PUSHER_APP_ID="{{ getenv "PUSHER_APP_ID" }}" +PUSHER_KEY="{{ getenv "PUSHER_KEY" }}" +PUSHER_SECRET="{{ getenv "PUSHER_SECRET" }}" +PUSHER_APP_CLUSTER="{{ getenv "PUSHER_APP_CLUSTER" }}" + +SENTRY_DSN="{{ getenv "SENTRY_DSN" }}" +LOGGLY_TOKEN="{{ getenv "LOGGLY_TOKEN" }}" + +AWS_ACCESS_KEY_ID="{{ getenv "AWS_ACCESS_KEY_ID" }}" +AWS_SECRET_ACCESS_KEY="{{ getenv "AWS_SECRET_ACCESS_KEY" }}" +AWS_DEFAULT_REGION="{{ getenv "AWS_DEFAULT_REGION" }}" +AWS_BUCKET="{{ getenv "AWS_BUCKET" }}" \ No newline at end of file diff --git a/tools/docker/usr/local/share/env/20-arc-env b/tools/docker/usr/local/share/env/20-arc-env index bd43cf9..c19d481 100644 --- a/tools/docker/usr/local/share/env/20-arc-env +++ b/tools/docker/usr/local/share/env/20-arc-env @@ -1,4 +1,17 @@ #!/bin/bash + +DEVELOPMENT_MODE=${DEVELOPMENT_MODE:-true} +DEVELOPMENT_MODE="$(convert_to_boolean_string "$DEVELOPMENT_MODE")" +export DEVELOPMENT_MODE + +COMPOSER_INSTALL_FLAGS="--no-interaction --optimize-autoloader --ignore-platform-reqs" + +if [ -z "$DEVELOPMENT_MODE" ] || [ "$DEVELOPMENT_MODE" != 'true' ]; then + DEFAULT_COMPOSER_FLAGS="${DEFAULT_COMPOSER_FLAGS} --no-dev " +fi + +export COMPOSER_INSTALL_FLAGS=${COMPOSER_INSTALL_FLAGS:-$COMPOSER_INSTALL_FLAGS} + START_MODE_CRON=${START_MODE_CRON:-true} START_MODE_CRON="$(convert_to_boolean_string "$START_MODE_CRON")" export START_MODE_CRON From 5b8712e67981363aa86005756d70e20dc2c2e8df Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Sat, 23 Feb 2019 20:17:41 +0000 Subject: [PATCH 2/2] Misc: Readme update --- README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8bf2417..db6cf60 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Arc -Bootstrap your new Laravel projects with package dependency installation and a highly configurable production ready Docker environment. +Bootstrap your new Laravel projects with a highly configurable production ready Docker environment. ## Overview -Arc is a simple Laravel package to add the ultimate docker environment for the majority of your applications. Built upon the amazing [ContinuousPipe Dockerfiles](https://github.com/continuouspipe/dockerfiles), this package will add the correct Dockerfile, Docker Compose and configurations into your Laravel project. Additionally, Arc will prompt you to install some package dependencies that are popular additions to any Laravel project. +Arc is a simple Laravel package to add the ultimate docker environment for the majority of your applications. Built upon the amazing [ContinuousPipe Dockerfiles](https://github.com/continuouspipe/dockerfiles), this package will add the correct Dockerfile, Docker Compose and configurations into your Laravel project. The Docker configuration provides the following - @@ -37,15 +37,7 @@ This package is intended for new Laravel >5.5 projects. php artisan arc:install ``` -The installer will ask if you would like to install the following packages. While some of these packages are not for every project they bring huge value to any project. - -Package | Description ---- | --- -[barryvdh/laravel-ide-helper](https://github.com/barryvdh/laravel-ide-helper) | This package generates a file that your IDE understands, so it can provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date. -[ellipsesynergie/api-response](https://github.com/ellipsesynergie/api-response) | Simple package to handle response properly in your API. This package uses [Fractal](https://github.com/thephpleague/fractal) and is based on [Build APIs You Won't Hate](https://leanpub.com/build-apis-you-wont-hate) book. -[genealabs/laravel-model-caching](https://github.com/genealabs/laravel-model-caching) | A package that abstracts the caching process into the model and provides self-invalidating relationship (only eager-loading) caching, query caching and automatic use of cache tags for cache providers that support them (will flush entire cache for providers that don't) -[lord/laroute](https://github.com/aaronlord/laroute) | This package ports the routes over to JavaScript, and gives a bunch of very familiar helper functions to use. -[laravel/horizon](https://github.com/laravel/horizon) | Horizon provides a beautiful dashboard and code-driven configuration for your Laravel powered Redis queues. Horizon allows you to easily monitor key metrics of your queue system such as job throughput, runtime, and job failures. +Once complete the installer will remove Arc as a composer dependency. #### Run the Container