[TASK] Cleanup and improve some options
This commit is contained in:
parent
dc3c80a2a9
commit
5151b22dc2
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Evoweb\DeployerConfig\Config;
|
namespace Evoweb\DeployerConfig\Config;
|
||||||
|
|
||||||
use Deployer\Deployer;
|
|
||||||
use Deployer\Exception\Exception;
|
use Deployer\Exception\Exception;
|
||||||
use Evoweb\DeployerConfig\Tasks\Deploy;
|
use Evoweb\DeployerConfig\Tasks\Deploy;
|
||||||
use Evoweb\DeployerConfig\Tasks\Local;
|
use Evoweb\DeployerConfig\Tasks\Local;
|
||||||
@ -17,38 +16,37 @@ use function Deployer\import;
|
|||||||
use function Deployer\parse;
|
use function Deployer\parse;
|
||||||
use function Deployer\runLocally;
|
use function Deployer\runLocally;
|
||||||
use function Deployer\set;
|
use function Deployer\set;
|
||||||
use function Deployer\Support\str_contains;
|
|
||||||
use function Deployer\testLocally;
|
use function Deployer\testLocally;
|
||||||
use function Deployer\warning;
|
use function Deployer\warning;
|
||||||
|
|
||||||
class Deployment
|
class Deployment
|
||||||
{
|
{
|
||||||
|
protected array $environmentVariables = [
|
||||||
|
'CI_PROJECT_DIR',
|
||||||
|
'CI_HOST',
|
||||||
|
'ENVIRONMENT',
|
||||||
|
'INSTANCE_ID'
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->loadDeployerCommon();
|
$this->loadDeployerCommon();
|
||||||
$this->setDefaultConfiguration();
|
$this->setDefaultConfiguration();
|
||||||
$this->loadHostConfiguration();
|
$this->loadHostConfiguration();
|
||||||
$this->registerTasks();
|
$this->registerTasks();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadDeployerCommon(): void
|
protected function loadDeployerCommon(): void
|
||||||
{
|
{
|
||||||
foreach (['/../../', '/../../../', '/../../../../'] as $path) {
|
$file = realpath(__DIR__ . '/../../../../deployer/deployer/recipe/common.php');
|
||||||
$file = realpath(__DIR__ . $path . 'vendor/deployer/deployer/recipe/common.php');
|
if ($file && file_exists($file)) {
|
||||||
if ($file && file_exists($file)) {
|
require $file;
|
||||||
require $file;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setDefaultConfiguration(): void
|
protected function setDefaultConfiguration(): void
|
||||||
{
|
{
|
||||||
$this->set('CI_PROJECT_DIR', getEnv('CI_PROJECT_DIR'));
|
array_walk($this->environmentVariables, fn ($variable) => $this->set($variable, getEnv($variable)));
|
||||||
$this->set('CI_HOST', getEnv('CI_HOST'));
|
|
||||||
$this->set('ENVIRONMENT_NAME', getEnv('ENVIRONMENT_NAME'));
|
|
||||||
$this->set('INSTANCE_ID', getEnv('INSTANCE_ID'));
|
|
||||||
|
|
||||||
$this->set('app_container_path', '');
|
$this->set('app_container_path', '');
|
||||||
|
|
||||||
@ -195,12 +193,9 @@ class Deployment
|
|||||||
protected function loadHostConfiguration(): void
|
protected function loadHostConfiguration(): void
|
||||||
{
|
{
|
||||||
// read configuration
|
// read configuration
|
||||||
foreach (['/../../../../', '/../../../../../'] as $path) {
|
$file = realpath(__DIR__ . '/../../../../../hosts.yaml');
|
||||||
$file = realpath(__DIR__ . $path . $_ENV['ENVIRONMENT_NAME'] . '.yaml');
|
if ($file && file_exists($file)) {
|
||||||
if (file_exists($file)) {
|
import($file);
|
||||||
import($file);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,6 @@ use ReflectionMethod;
|
|||||||
use function Deployer\get;
|
use function Deployer\get;
|
||||||
use function Deployer\has;
|
use function Deployer\has;
|
||||||
use function Deployer\set;
|
use function Deployer\set;
|
||||||
use function Deployer\test;
|
|
||||||
use function Deployer\testLocally;
|
use function Deployer\testLocally;
|
||||||
|
|
||||||
abstract class AbstractTasks
|
abstract class AbstractTasks
|
||||||
@ -102,26 +101,4 @@ abstract class AbstractTasks
|
|||||||
{
|
{
|
||||||
return $this->has($name) && is_array($this->get($name));
|
return $this->has($name) && is_array($this->get($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getApplicationContext(): string
|
|
||||||
{
|
|
||||||
return $this->has('application_context') ?
|
|
||||||
'TYPO3_CONTEXT="' . $this->get('application_context') . '" ' :
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getSudo(): string
|
|
||||||
{
|
|
||||||
return $this->get('clear_use_sudo') ? 'sudo ' : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getTYPO3Bin(string $path, string $testPath): string
|
|
||||||
{
|
|
||||||
if (test('[ -f ' . $testPath . '/releases/{{release_name}}/vendor/bin/typo3cms ]')) {
|
|
||||||
$bin = $path . '/releases/{{release_name}}/vendor/bin/typo3cms';
|
|
||||||
} else {
|
|
||||||
$bin = $path . '/releases/{{release_name}}/vendor/bin/typo3';
|
|
||||||
}
|
|
||||||
return $bin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ class Deploy extends AbstractTasks
|
|||||||
'local:shared',
|
'local:shared',
|
||||||
'local:writable',
|
'local:writable',
|
||||||
'local:write_release',
|
'local:write_release',
|
||||||
'local:create_folder',
|
|
||||||
'local:vendors',
|
'local:vendors',
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -41,17 +40,21 @@ class Deploy extends AbstractTasks
|
|||||||
'local:unlock',
|
'local:unlock',
|
||||||
'deploy:success',
|
'deploy:success',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'deploy' => [
|
||||||
|
'deploy:prepare',
|
||||||
|
'deploy:publish',
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct()
|
protected function initializeTasks(): void
|
||||||
{
|
{
|
||||||
parent::__construct();
|
array_walk($this->tasks, [$this, 'registerTask']);
|
||||||
$this->registerAfterTask();
|
$this->registerAfterTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function registerAfterTask(): void
|
protected function registerAfterTask(): void
|
||||||
{
|
{
|
||||||
// [Optional] if deploy fails automatically unlock.
|
|
||||||
after('deploy:failed', 'local:unlock');
|
after('deploy:failed', 'local:unlock');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@ class Local extends AbstractTasks
|
|||||||
'local:shared',
|
'local:shared',
|
||||||
'local:writable',
|
'local:writable',
|
||||||
'local:write_release',
|
'local:write_release',
|
||||||
'local:create_folder',
|
|
||||||
'local:vendors',
|
'local:vendors',
|
||||||
'local:clear_paths',
|
'local:clear_paths',
|
||||||
'local:symlink',
|
'local:symlink',
|
||||||
@ -88,15 +87,6 @@ class Local extends AbstractTasks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unlocks deploy
|
|
||||||
*/
|
|
||||||
public function unlock(): void
|
|
||||||
{
|
|
||||||
// always success
|
|
||||||
runLocally("rm -f {{deploy_path}}/.dep/deploy.lock");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares release
|
* Prepares release
|
||||||
*/
|
*/
|
||||||
@ -313,21 +303,23 @@ class Local extends AbstractTasks
|
|||||||
throw new \RuntimeException('Absolute path not allowed in config parameter `writable_dirs`.');
|
throw new \RuntimeException('Absolute path not allowed in config parameter `writable_dirs`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$options = ['cwd' => $this->get('release_or_current_path')];
|
||||||
|
|
||||||
// Create directories if they don't exist
|
// Create directories if they don't exist
|
||||||
runLocally("cd {{release_or_current_path}}; mkdir -p $dirs");
|
runLocally("mkdir -p $dirs", $options);
|
||||||
|
|
||||||
if ($mode === 'chown') {
|
if ($mode === 'chown') {
|
||||||
$httpUser = get('http_user');
|
$httpUser = get('http_user');
|
||||||
// Change owner.
|
// Change owner.
|
||||||
// -L traverse every symbolic link to a directory encountered
|
// -L traverse every symbolic link to a directory encountered
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo chown -L $recursive $httpUser $dirs");
|
runLocally("$sudo chown -L $recursive $httpUser $dirs", $options);
|
||||||
} elseif ($mode === 'chgrp') {
|
} elseif ($mode === 'chgrp') {
|
||||||
// Change group ownership.
|
// Change group ownership.
|
||||||
// -L traverse every symbolic link to a directory encountered
|
// -L traverse every symbolic link to a directory encountered
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo chgrp -L $recursive {{http_group}} $dirs");
|
runLocally("$sudo chgrp -L $recursive {{http_group}} $dirs", $options);
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo chmod $recursive g+rwx $dirs");
|
runLocally("$sudo chmod $recursive g+rwx $dirs", $options);
|
||||||
} elseif ($mode === 'chmod') {
|
} elseif ($mode === 'chmod') {
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo chmod $recursive {{writable_chmod_mode}} $dirs");
|
runLocally("$sudo chmod $recursive {{writable_chmod_mode}} $dirs", $options);
|
||||||
} elseif ($mode === 'acl') {
|
} elseif ($mode === 'acl') {
|
||||||
$remoteUser = get('remote_user', false);
|
$remoteUser = get('remote_user', false);
|
||||||
if (empty($remoteUser)) {
|
if (empty($remoteUser)) {
|
||||||
@ -337,7 +329,7 @@ class Local extends AbstractTasks
|
|||||||
if (strlen(runLocally("chmod --help | grep ugoa; true")) > 0) {
|
if (strlen(runLocally("chmod --help | grep ugoa; true")) > 0) {
|
||||||
// Try OS-X specific setting of access-rights
|
// Try OS-X specific setting of access-rights
|
||||||
|
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo chmod g+w $dirs");
|
runLocally("$sudo chmod g+w $dirs", $options);
|
||||||
} elseif ($this->commandExist('setfacl')) {
|
} elseif ($this->commandExist('setfacl')) {
|
||||||
$setFaclUsers = "-m u:\"$httpUser\":rwX";
|
$setFaclUsers = "-m u:\"$httpUser\":rwX";
|
||||||
// Check if remote user exists, before adding it to setfacl
|
// Check if remote user exists, before adding it to setfacl
|
||||||
@ -353,16 +345,16 @@ class Local extends AbstractTasks
|
|||||||
$writeableDirs = get('writable_dirs');
|
$writeableDirs = get('writable_dirs');
|
||||||
foreach ($writeableDirs as $dir) {
|
foreach ($writeableDirs as $dir) {
|
||||||
// Check if ACL has been set or not
|
// Check if ACL has been set or not
|
||||||
$hasfacl = runLocally("cd {{release_or_current_path}}; getfacl -p $dir | grep \"^user:$httpUser:.*w\" | wc -l");
|
$hasfacl = runLocally("getfacl -p $dir | grep \"^user:$httpUser:.*w\" | wc -l", $options);
|
||||||
// Set ACL for directory if it has not been set before
|
// Set ACL for directory if it has not been set before
|
||||||
if (!$hasfacl) {
|
if (!$hasfacl) {
|
||||||
runLocally("cd {{release_or_current_path}}; setfacl -L $recursive $setFaclUsers $dir");
|
runLocally("setfacl -L $recursive $setFaclUsers $dir", $options);
|
||||||
runLocally("cd {{release_or_current_path}}; setfacl -dL $recursive $setFaclUsers $dir");
|
runLocally("setfacl -dL $recursive $setFaclUsers $dir", $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo setfacl -L $recursive $setFaclUsers $dirs");
|
runLocally("$sudo setfacl -L $recursive $setFaclUsers $dirs", $options);
|
||||||
runLocally("cd {{release_or_current_path}}; $sudo setfacl -dL $recursive $setFaclUsers $dirs");
|
runLocally("$sudo setfacl -dL $recursive $setFaclUsers $dirs", $options);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$alias = currentHost()->getAlias();
|
$alias = currentHost()->getAlias();
|
||||||
@ -371,12 +363,12 @@ class Local extends AbstractTasks
|
|||||||
} elseif ($mode === 'sticky') {
|
} elseif ($mode === 'sticky') {
|
||||||
// Changes the group of the files, sets sticky bit to the directories
|
// Changes the group of the files, sets sticky bit to the directories
|
||||||
// and add the writable bit for all files
|
// and add the writable bit for all files
|
||||||
runLocally("cd {{release_or_current_path}}; for dir in $dirs;" .
|
runLocally("for dir in $dirs;" .
|
||||||
'do ' .
|
'do ' .
|
||||||
'chgrp -L -R {{http_group}} ${dir}; ' .
|
'chgrp -L -R {{http_group}} ${dir}; ' .
|
||||||
'find ${dir} -type d -exec chmod g+rwxs \{\} \;;' .
|
'find ${dir} -type d -exec chmod g+rwxs \{\} \;;' .
|
||||||
'find ${dir} -type f -exec chmod g+rw \{\} \;;' .
|
'find ${dir} -type f -exec chmod g+rw \{\} \;;' .
|
||||||
'done');
|
'done', $options);
|
||||||
} elseif ($mode === 'skip') {
|
} elseif ($mode === 'skip') {
|
||||||
// Does nothing, saves time if no changes are required for some environments
|
// Does nothing, saves time if no changes are required for some environments
|
||||||
return;
|
return;
|
||||||
@ -390,24 +382,6 @@ class Local extends AbstractTasks
|
|||||||
runLocally('echo {{target}} > {{release_path}}/release');
|
runLocally('echo {{target}} > {{release_path}}/release');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creating necessary folders
|
|
||||||
*/
|
|
||||||
public function createFolder(): void
|
|
||||||
{
|
|
||||||
$sudo = $this->getSudo();
|
|
||||||
|
|
||||||
if (testLocally('[ ! -d {{release_path}}/var/cache ]')) {
|
|
||||||
runLocally('mkdir -p {{release_path}}/var/cache');
|
|
||||||
}
|
|
||||||
runLocally($sudo . ' chmod -R 775 {{release_path}}/var/cache');
|
|
||||||
|
|
||||||
if (testLocally('[ ! -d {{release_path}}/var/log ]')) {
|
|
||||||
runLocally('mkdir -p {{release_path}}/var/log');
|
|
||||||
}
|
|
||||||
runLocally($sudo . ' chmod -R 775 {{release_path}}/var/log');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installing vendors
|
* Installing vendors
|
||||||
*/
|
*/
|
||||||
@ -483,4 +457,13 @@ class Local extends AbstractTasks
|
|||||||
{
|
{
|
||||||
info('Folder of this release is: {{release_path}}');
|
info('Folder of this release is: {{release_path}}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlocks deploy
|
||||||
|
*/
|
||||||
|
public function unlock(): void
|
||||||
|
{
|
||||||
|
// always success
|
||||||
|
runLocally("rm -f {{deploy_path}}/.dep/deploy.lock");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Evoweb\DeployerConfig\Tasks;
|
namespace Evoweb\DeployerConfig\Tasks;
|
||||||
|
|
||||||
|
use function Deployer\currentHost;
|
||||||
use function Deployer\get;
|
use function Deployer\get;
|
||||||
use function Deployer\parse;
|
use function Deployer\parse;
|
||||||
use function Deployer\run;
|
use function Deployer\run;
|
||||||
@ -158,8 +159,29 @@ class Remote extends AbstractTasks
|
|||||||
*/
|
*/
|
||||||
public function clearOpcache(): void
|
public function clearOpcache(): void
|
||||||
{
|
{
|
||||||
$webDomain = rtrim($this->get('web_domain'), '/');
|
|
||||||
$htaccess = $this->has('htaccess') ? '--user ' . $this->get('htaccess') : '';
|
$htaccess = $this->has('htaccess') ? '--user ' . $this->get('htaccess') : '';
|
||||||
run('curl ' . $htaccess . ' -sk ' . $webDomain . '/cache.php');
|
run('curl ' . $htaccess . ' -sk https://' . currentHost()->getAlias() . '/cache.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSudo(): string
|
||||||
|
{
|
||||||
|
return $this->get('clear_use_sudo') ? 'sudo ' : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getApplicationContext(): string
|
||||||
|
{
|
||||||
|
return $this->has('application_context') ?
|
||||||
|
'TYPO3_CONTEXT="' . $this->get('application_context') . '" ' :
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTYPO3Bin(string $path, string $testPath): string
|
||||||
|
{
|
||||||
|
if (test('[ -f ' . $testPath . '/releases/{{release_name}}/vendor/bin/typo3cms ]')) {
|
||||||
|
$bin = $path . '/releases/{{release_name}}/vendor/bin/typo3cms';
|
||||||
|
} else {
|
||||||
|
$bin = $path . '/releases/{{release_name}}/vendor/bin/typo3';
|
||||||
|
}
|
||||||
|
return $bin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,8 +55,6 @@ class Rsync extends AbstractTasks
|
|||||||
|
|
||||||
$this->set('rsync_default', $this->defaultConfig);
|
$this->set('rsync_default', $this->defaultConfig);
|
||||||
|
|
||||||
$this->set('rsync_src', '{{deploy_path}}');
|
|
||||||
|
|
||||||
$this->set('rsync_dest', '{{user}}@{{hostname}}:\'{{remote_path}}/\'');
|
$this->set('rsync_dest', '{{user}}@{{hostname}}:\'{{remote_path}}/\'');
|
||||||
|
|
||||||
$this->set('rsync_config', $this->rsyncConfig(...));
|
$this->set('rsync_config', $this->rsyncConfig(...));
|
||||||
@ -87,18 +85,22 @@ class Rsync extends AbstractTasks
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (testLocally('[ -d "{{deploy_path}}" ]')) {
|
if (testLocally('[ -d "{{deploy_path}}" ]')) {
|
||||||
|
$config = $this->get('rsync_config');
|
||||||
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
||||||
runLocally(
|
runLocally(
|
||||||
'rsync \
|
'
|
||||||
-e \'ssh -p {{port}}' . $identityFile . '\' \
|
rsync \
|
||||||
{{rsync_flags}} \
|
-e "ssh -p {{port}}' . $identityFile . '" \
|
||||||
{{rsync_options}} \
|
{{rsync_flags}} \
|
||||||
{{rsync_timeout}} \
|
{{rsync_options}} \
|
||||||
--exclude=' . escapeshellarg('shared') . ' \
|
{{rsync_timeout}} \
|
||||||
{{rsync_excludes_download}} \
|
--exclude=' . escapeshellarg('shared') . ' \
|
||||||
{{rsync_includes}} \
|
{{rsync_excludes_download}} \
|
||||||
{{rsync_filter}} \
|
{{rsync_includes}} \
|
||||||
{{rsync_dest}} {{deploy_path}}'
|
{{rsync_filter}} \
|
||||||
|
{{rsync_dest}} {{deploy_path}}
|
||||||
|
',
|
||||||
|
$config
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
warning('<comment>No destination folder found.</comment>');
|
warning('<comment>No destination folder found.</comment>');
|
||||||
@ -110,20 +112,22 @@ class Rsync extends AbstractTasks
|
|||||||
*/
|
*/
|
||||||
public function remote(): void
|
public function remote(): void
|
||||||
{
|
{
|
||||||
$config = $this->get('rsync_config');
|
|
||||||
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
|
||||||
if (test('[ -d "{{remote_path}}" ]')) {
|
if (test('[ -d "{{remote_path}}" ]')) {
|
||||||
|
$config = $this->get('rsync_config');
|
||||||
|
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
||||||
runLocally(
|
runLocally(
|
||||||
'rsync \
|
'
|
||||||
-e \'ssh -p {{port}}' . $identityFile . '\' \
|
rsync \
|
||||||
{{rsync_flags}} \
|
-e "ssh -p {{port}}' . $identityFile . '" \
|
||||||
{{rsync_options}} \
|
{{rsync_flags}} \
|
||||||
{{rsync_timeout}} \
|
{{rsync_options}} \
|
||||||
{{rsync_includes}} \
|
{{rsync_timeout}} \
|
||||||
--exclude=' . escapeshellarg('shared/') . ' \
|
{{rsync_includes}} \
|
||||||
{{rsync_excludes_upload}} \
|
--exclude=' . escapeshellarg('shared/') . ' \
|
||||||
{{rsync_filter}} \
|
{{rsync_excludes_upload}} \
|
||||||
\'{{rsync_src}}/\' {{user}}@{{hostname}}:\'{{remote_path}}/\'',
|
{{rsync_filter}} \
|
||||||
|
{{deploy_path}}/ {{rsync_dest}}
|
||||||
|
',
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -139,11 +143,13 @@ class Rsync extends AbstractTasks
|
|||||||
$config = $this->get('rsync_config');
|
$config = $this->get('rsync_config');
|
||||||
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
$identityFile = $this->get('identity_file') ? ' -i ' . $this->get('identity_file') : '';
|
||||||
runLocally(
|
runLocally(
|
||||||
'rsync \
|
'
|
||||||
-e \'ssh -p {{port}}' . $identityFile . '\' \
|
rsync \
|
||||||
|
-e "ssh -p {{port}}' . $identityFile . '" \
|
||||||
{{rsync_flags}} \
|
{{rsync_flags}} \
|
||||||
{{rsync_options}} \
|
{{rsync_options}} \
|
||||||
\'{{rsync_src}}/current\' {{user}}@{{hostname}}:\'{{remote_path}}/\'',
|
{{deploy_path}}/current {{rsync_dest}}
|
||||||
|
',
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
101
README.md
101
README.md
@ -28,7 +28,7 @@ function composer() {
|
|||||||
--env SSH_AUTH_SOCK=/ssh-agent \
|
--env SSH_AUTH_SOCK=/ssh-agent \
|
||||||
--env CI_HOST \
|
--env CI_HOST \
|
||||||
--env CI_PROJECT_DIR \
|
--env CI_PROJECT_DIR \
|
||||||
--env ENVIRONMENT_NAME \
|
--env ENVIRONMENT \
|
||||||
--env INSTANCE_ID \
|
--env INSTANCE_ID \
|
||||||
--env ADDITIONAL_CONFIG_FILE \
|
--env ADDITIONAL_CONFIG_FILE \
|
||||||
--env TYPO3_CONTEXT \
|
--env TYPO3_CONTEXT \
|
||||||
@ -75,9 +75,9 @@ _ARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
|
|||||||
# ...and turn them into do-nothing targets
|
# ...and turn them into do-nothing targets
|
||||||
$(eval $(_ARGS):;@:)
|
$(eval $(_ARGS):;@:)
|
||||||
|
|
||||||
production-%: ENVIRONMENT_NAME=production
|
production-%: ENVIRONMENT=production
|
||||||
production-%: TYPO3_CONTEXT=Production
|
production-%: TYPO3_CONTEXT=Production
|
||||||
staging-%: ENVIRONMENT_NAME=staging
|
staging-%: ENVIRONMENT=staging
|
||||||
staging-%: TYPO3_CONTEXT=Production/Staging
|
staging-%: TYPO3_CONTEXT=Production/Staging
|
||||||
|
|
||||||
MKFILE_PATH := $(realpath $(firstword $(MAKEFILE_LIST)))
|
MKFILE_PATH := $(realpath $(firstword $(MAKEFILE_LIST)))
|
||||||
@ -103,11 +103,11 @@ latest-tag:
|
|||||||
|
|
||||||
.PHONY: --release
|
.PHONY: --release
|
||||||
--release:
|
--release:
|
||||||
echo "Release for $(ENVIRONMENT_NAME) with '$(TASK)' started"
|
echo "Release for $(ENVIRONMENT) with '$(TASK)' started"
|
||||||
source $(ALIAS_FILE); \
|
source $(ALIAS_FILE); \
|
||||||
ENVIRONMENT_NAME="$(ENVIRONMENT_NAME)" \
|
ENVIRONMENT="$(ENVIRONMENT)" \
|
||||||
composer --working-dir=$(BUILD_DIR) exec dep -- $(VERBOSE) --file=$(DEPLOY_FILE) $(TASK)
|
composer --working-dir=$(BUILD_DIR) exec dep -- $(VERBOSE) --file=$(DEPLOY_FILE) $(TASK) environment=$(ENVIRONMENT)
|
||||||
echo "Release for $(ENVIRONMENT_NAME) with '$(TASK)' finished"
|
echo "Release for $(ENVIRONMENT) with '$(TASK)' finished"
|
||||||
|
|
||||||
##@
|
##@
|
||||||
##@ Commands to release tag or branch
|
##@ Commands to release tag or branch
|
||||||
@ -139,68 +139,26 @@ Deploy tag 1.0.0 to production
|
|||||||
make production-release 1.0.0
|
make production-release 1.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Overriding default values per host in production.yaml
|
## Overriding default values per host in hosts.yaml
|
||||||
```yaml
|
```yaml
|
||||||
# for more settings look in https://github.com/deployphp/deployer/recipe/common.php
|
# for more settings, look in https://github.com/deployphp/deployer/recipe/common.php
|
||||||
config:
|
|
||||||
bin/php: 'docker exec -e TYPO3_CONTEXT="{{application_context}}" $(docker ps -q -f name={{INSTANCE_ID}}-php-fpm-1) php'
|
|
||||||
http_user: sebastian
|
|
||||||
http_group: www-data
|
|
||||||
keep_releases: 10
|
|
||||||
|
|
||||||
repository: git@gitea.fischer.im:evoWeb/website_evoweb_de.git
|
|
||||||
composer_options: '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest --ignore-platform-reqs'
|
|
||||||
|
|
||||||
prepare_dirs:
|
|
||||||
- .dep
|
|
||||||
- releases
|
|
||||||
- shared/fileadmin
|
|
||||||
|
|
||||||
shared_dirs:
|
|
||||||
- fileadmin
|
|
||||||
|
|
||||||
writable_recursive: true
|
|
||||||
writable_dirs:
|
|
||||||
- public/typo3temp
|
|
||||||
- var
|
|
||||||
|
|
||||||
rsync:
|
|
||||||
exclude_download:
|
|
||||||
- 'current'
|
|
||||||
- 'shared/'
|
|
||||||
- 'var/*'
|
|
||||||
- '-,p public/typo3temp'
|
|
||||||
|
|
||||||
remote_path: /srv/{{INSTANCE_ID}}/data/htdocs/production
|
|
||||||
app_container_path: /usr/local/apache2/htdocs/production
|
|
||||||
application_context: Production
|
|
||||||
web_domain: https://www.evoweb.de/
|
|
||||||
|
|
||||||
|
|
||||||
hosts:
|
|
||||||
production:
|
|
||||||
remote_user: sebastian
|
|
||||||
hostname: '{{CI_HOST}}'
|
|
||||||
deploy_path: '{{CI_PROJECT_DIR}}/Build/cache/{{ENVIRONMENT_NAME}}'
|
|
||||||
identity_file: ~/.ssh/rsync_id_ed25519
|
|
||||||
```
|
|
||||||
|
|
||||||
## Overriding default values per host in staging.yaml
|
|
||||||
```yaml
|
|
||||||
# for more settings look in https://github.com/deployphp/deployer/recipe/common.php
|
|
||||||
config:
|
config:
|
||||||
bin/php: 'docker exec -e TYPO3_CONTEXT="{{application_context}}" $(docker ps -q -f name={{INSTANCE_ID}}-php-fpm-1) php'
|
bin/php: 'docker exec -e TYPO3_CONTEXT="{{application_context}}" $(docker ps -q -f name={{INSTANCE_ID}}-php-fpm-1) php'
|
||||||
http_user: sebastian
|
http_user: sebastian
|
||||||
http_group: www-data
|
http_group: www-data
|
||||||
keep_releases: 5
|
keep_releases: 5
|
||||||
|
|
||||||
|
remote_user: sebastian
|
||||||
|
identity_file: ~/.ssh/rsync_id_ed25519
|
||||||
|
deploy_path: '{{CI_PROJECT_DIR}}/Build/cache/{{ENVIRONMENT}}'
|
||||||
|
|
||||||
repository: git@gitea.fischer.im:evoWeb/website_evoweb_de.git
|
repository: git@gitea.fischer.im:evoWeb/website_evoweb_de.git
|
||||||
composer_options: '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest --ignore-platform-reqs'
|
composer_options: '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest --ignore-platform-reqs'
|
||||||
|
|
||||||
prepare_dirs:
|
prepare_dirs:
|
||||||
- .dep
|
- .dep
|
||||||
- releases
|
- releases
|
||||||
- shared/fileadmin
|
- shared/public/fileadmin
|
||||||
|
|
||||||
shared_dirs:
|
shared_dirs:
|
||||||
- public/fileadmin
|
- public/fileadmin
|
||||||
@ -209,24 +167,31 @@ config:
|
|||||||
writable_dirs:
|
writable_dirs:
|
||||||
- public/typo3temp
|
- public/typo3temp
|
||||||
- var
|
- var
|
||||||
|
- var/cache
|
||||||
|
- var/log
|
||||||
|
|
||||||
rsync:
|
rsync:
|
||||||
exclude_download:
|
exclude_download:
|
||||||
- 'current'
|
- current
|
||||||
- 'shared/'
|
- shared/
|
||||||
- 'var/*'
|
- var/*
|
||||||
- '-,p public/typo3temp'
|
- '-,p public/typo3temp'
|
||||||
|
|
||||||
remote_path: /srv/{{INSTANCE_ID}}/data/htdocs/staging
|
remote_path: /srv/{{INSTANCE_ID}}/data/htdocs/{{ENVIRONMENT}}
|
||||||
app_container_path: /usr/local/apache2/htdocs/staging
|
app_container_path: /usr/local/apache2/htdocs/{{ENVIRONMENT}}
|
||||||
application_context: Production/Staging
|
|
||||||
web_domain: https://staging.evoweb.de/
|
|
||||||
htaccess: evoweb:website
|
|
||||||
|
|
||||||
hosts:
|
hosts:
|
||||||
staging:
|
staging.evoweb.de:
|
||||||
remote_user: sebastian
|
|
||||||
hostname: '{{CI_HOST}}'
|
hostname: '{{CI_HOST}}'
|
||||||
deploy_path: '{{CI_PROJECT_DIR}}/Build/cache/{{ENVIRONMENT_NAME}}'
|
labels:
|
||||||
identity_file: ~/.ssh/rsync_id_ed25519
|
environment: staging
|
||||||
|
application_context: Production/Staging
|
||||||
|
htaccess: evoweb:website
|
||||||
|
|
||||||
|
www.evoweb.de:
|
||||||
|
hostname: '{{CI_HOST}}'
|
||||||
|
labels:
|
||||||
|
environment: production
|
||||||
|
application_context: Production
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
2
alias.sh
2
alias.sh
@ -9,7 +9,7 @@ function composer() {
|
|||||||
--env SSH_AUTH_SOCK=/ssh-agent \
|
--env SSH_AUTH_SOCK=/ssh-agent \
|
||||||
--env CI_HOST \
|
--env CI_HOST \
|
||||||
--env CI_PROJECT_DIR \
|
--env CI_PROJECT_DIR \
|
||||||
--env ENVIRONMENT_NAME \
|
--env ENVIRONMENT \
|
||||||
--env INSTANCE_ID \
|
--env INSTANCE_ID \
|
||||||
--env ADDITIONAL_CONFIG_FILE \
|
--env ADDITIONAL_CONFIG_FILE \
|
||||||
--env TYPO3_CONTEXT \
|
--env TYPO3_CONTEXT \
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$classLoader = require dirname(__DIR__) . '/../vendor/autoload.php';
|
require(dirname(__DIR__) . '/../../vendor/autoload.php');
|
||||||
new \Evoweb\DeployerConfig\Config\Deployment();
|
new \Evoweb\DeployerConfig\Config\Deployment();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user