forked from FlorianMoser/bedrock-deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create .env.deployer for configuration. Update Readme
- Loading branch information
1 parent
f933c56
commit e4f3c5a
Showing
7 changed files
with
151 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* Holds default configuration. Copy and paste set-methods to your deploy.php to overwrite them. | ||
*/ | ||
|
||
namespace Deployer; | ||
|
||
require(__DIR__ . '/../../../autoload.php'); | ||
|
||
use Dotenv\Dotenv; | ||
|
||
// .env.deployer will be generated on first run. | ||
if (file_exists(get('local_root').'/.env.deployer')) { | ||
$localEnv = Dotenv::createUnsafeImmutable(get('local_root'), '.env.deployer'); | ||
$localEnv->load(); | ||
} | ||
|
||
require __DIR__ . '/../../../deployer/deployer/recipe/common.php'; | ||
require __DIR__ . '/../recipe/recipes.php'; | ||
|
||
// CLI Configuration | ||
// set('bin/composer', function () { return 'composer'; }); | ||
set('bin/composer', function () { return '/opt/plesk/php/8.1/bin/php /usr/lib/plesk-9.0/composer.phar'; }); | ||
set('composer_options', 'install --verbose --no-interaction'); | ||
// Download wp-cli.phar | ||
set('bin/wp', function () { | ||
run("cd {{deploy_path}} && curl -sS -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar"); | ||
run('mv {{deploy_path}}/wp-cli.phar {{deploy_path}}/.dep/wp-cli.phar'); | ||
return '{{bin/php}} {{deploy_path}}/.dep/wp-cli.phar'; | ||
}); | ||
|
||
// Common Deployer config | ||
set('keep_releases', function () { return getenv('KEEP_RELEASES'); }); | ||
set( 'repository', function () { return getenv('REPO'); }); | ||
set( 'shared_dirs', ['web/app/uploads'] ); | ||
set( 'domain', basename(get('local_root')) ); | ||
|
||
// Bedrock DB config | ||
set( 'vagrant_dir', get('local_root') . '/../trellis' ); | ||
set( 'vagrant_root', '/srv/www/' . get('domain') . '/current' ); | ||
|
||
// Bedrock DB and Sage config | ||
set( 'theme_path', function () { return getenv('THEME_PATH'); }); | ||
|
||
// File transfer config | ||
set( 'sync_dirs', [ | ||
get('local_root') . '/web/app/uploads/' => '{{deploy_path}}/shared/web/app/uploads/', | ||
] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Deploy with `php vendor/bin/dep deploy stage` | ||
* - Deploy with `php vendor/bin/dep deploy stage` | ||
* - Set Webspace Path to 'current/web' | ||
*/ | ||
|
||
namespace Deployer; | ||
|
||
require 'vendor/deployer/deployer/recipe/common.php'; | ||
require 'vendor/mmoollllee/bedrock-deployer/recipe/recipes.php'; | ||
// Configurate Hostname of stage & production | ||
$hostname = 'example.com'; | ||
$stage_hostname = $hostname; | ||
|
||
// Configuration | ||
set('bin/composer', function () { return '/opt/plesk/php/8.1/bin/php /usr/lib/plesk-9.0/composer.phar'; }); // set('bin/composer', function () { return 'composer'; }); | ||
set('composer_options', 'install --verbose --no-interaction'); | ||
set('bin/wp', function () { | ||
run("cd {{deploy_path}} && curl -sS -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar"); | ||
run('mv {{deploy_path}}/wp-cli.phar {{deploy_path}}/.dep/wp-cli.phar'); | ||
return '{{bin/php}} {{deploy_path}}/.dep/wp-cli.phar'; | ||
}); | ||
// get directory of projects. Will be used for domain name,... | ||
set( 'local_root', dirname( __FILE__ ) ); | ||
|
||
// Common Deployer config | ||
set( 'repository', '[email protected]:example/example.git' ); | ||
set( 'shared_dirs', ['web/app/uploads'] ); | ||
|
||
// Bedrock DB config | ||
set( 'vagrant_dir', dirname( __FILE__ ) . '/../trellis' ); | ||
set( 'vagrant_root', '/srv/www/example.com/current' ); | ||
|
||
// Bedrock DB and Sage config | ||
set( 'local_root', dirname( __FILE__ ) );; | ||
set( 'theme_path', 'web/app/themes/template' ); | ||
|
||
// File transfer config | ||
set( 'sync_dirs', [ | ||
dirname( __FILE__ ) . '/web/app/uploads/' => '{{deploy_path}}/shared/web/app/uploads/', | ||
] ); | ||
|
||
// Hosts | ||
require 'vendor/mmoollllee/bedrock-deployer/config/config.php'; | ||
|
||
// set | ||
host( 'stage' ) | ||
->setHostname( 'example.com' ) | ||
->set('remote_user', 'user') | ||
->set( 'deploy_path', '~/httpdocs/deploy' ); | ||
// Set Webspace-Path to ~/stage/deploy/current/web/ | ||
->setHostname( $stage_hostname ) | ||
->set('remote_user', function () { return getenv('STAGE_USERNAME') ?: getenv('USERNAME'); }) | ||
->set('deploy_path', function () { return getenv('STAGE_DIR'); }); | ||
|
||
host( 'prod' ) | ||
->setHostname( 'example.com' ) | ||
->set('remote_user', 'user') | ||
->set( 'deploy_path', '~/httpdocs/deploy' ); | ||
|
||
->setHostname( $hostname ) | ||
->set('remote_user', function () { return getenv('USERNAME'); }) | ||
->set('deploy_path', function () { return getenv('DIR'); }); | ||
|
||
// Tasks | ||
desc( 'Deploy whole project' ); | ||
task( 'deploy', [ | ||
'deployer:check', | ||
'bedrock:prepare', | ||
'deploy:lock', | ||
'deploy:release', | ||
|
@@ -73,6 +52,7 @@ | |
|
||
desc( 'Deploy only app' ); | ||
task( 'update', [ | ||
'deployer:check', | ||
'bedrock:prepare', | ||
'deploy:lock', | ||
'deploy:release', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* Check for configuration files before starting | ||
*/ | ||
|
||
namespace Deployer; | ||
|
||
/* | ||
* Check for .env.deployer and if not present, create it | ||
*/ | ||
|
||
desc( '.env.deployer present?' ); | ||
task( 'deployer:check', function () { | ||
|
||
// Check if local .env.deployer exists | ||
if ( testLocally('[ -f {{local_root}}/.env.deployer ]')) { | ||
return; | ||
} | ||
|
||
// If not create one | ||
|
||
writeln( '<comment>Generating .env.deployer file</comment>' ); | ||
|
||
// Ask for credentials | ||
$repo = ask( 'Bedrock Repository' ); | ||
$prod_dir = ask( 'Production Directory', '~/httpdocs' ); | ||
$stage_dir = ask( 'Stage Directory', '~/stage.'.get('domain') ); | ||
$prod_user = ask( 'Production Username' ); | ||
$stage_user = ask( 'Stage Username', $prod_user ); | ||
$theme_name = ask( 'themes name for template_path?', 'template' ); | ||
$keep_releases = ask( 'Releases to keep', '4' ); | ||
|
||
ob_start(); | ||
|
||
echo <<<EOL | ||
REPO='{$repo}' | ||
DIR='{$prod_dir}' | ||
STAGE_DIR='{$stage_dir}' | ||
USERNAME='{$prod_user}' | ||
STAGE_USERNAME='{$stage_user}' | ||
THEME_PATH='web/app/themes/{$theme_name}' | ||
KEEP_RELEASES={$keep_releases} | ||
EOL; | ||
|
||
$content = ob_get_clean(); | ||
|
||
|
||
|
||
runLocally( 'echo "' . $content . '" > {{local_root}}/.env.deployer' ); | ||
|
||
writeln( '<comment>Rerun task please</comment>' ); | ||
return; | ||
|
||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters