diff --git a/composer.json b/composer.json
index 0da432140..6080064c2 100644
--- a/composer.json
+++ b/composer.json
@@ -60,13 +60,13 @@
"symfony/web-profiler-bundle": "5.4.*",
"netgen/git-hooks": "^2.3",
- "deployer/recipes": "^6.2",
"phpstan/phpstan": "^1.9",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan-symfony": "^1.2",
"phpstan/phpstan-doctrine": "^1.3",
- "php-cs-fixer/shim": "^3.20"
+ "php-cs-fixer/shim": "^3.20",
+ "deployer/deployer": "^7.3"
},
"config": {
"allow-plugins": {
diff --git a/deploy.php b/deploy.php
index 6c4847d6a..23fadff40 100644
--- a/deploy.php
+++ b/deploy.php
@@ -2,11 +2,10 @@
namespace Deployer;
-require 'recipe/symfony4.php';
-require 'vendor/deployer/recipes/recipe/cachetool.php';
-require 'vendor/deployer/recipes/recipe/rsync.php';
-require 'vendor/deployer/recipes/recipe/sentry.php';
-require 'vendor/deployer/recipes/recipe/slack.php';
+require 'recipe/symfony.php';
+require 'contrib/rsync.php';
+require 'contrib/sentry.php';
+require 'contrib/cachetool.php';
require __DIR__ . '/deploy/hosts.php';
require __DIR__ . '/deploy/tasks/server.php';
@@ -24,9 +23,12 @@
// optional: slack integration
//require __DIR__ . '/deploy/tasks/slack.php';
+
/** Parameters */
set('git_tty', true);
+set('git_ssh_command', 'ssh');
+
add('copy_dirs', ['vendor']);
set('use_relative_symlink', false);
@@ -39,6 +41,10 @@
'commits' => getCommitsInformation()
]);
+set('writable_recursive', true);
+
+set('update_code_strategy', 'clone');
+
/** Execution */
task('deploy', [
'deploy:confirm',
@@ -46,11 +52,7 @@
'server:upload_env',
'deploy:info',
'deploy:prepare',
- 'deploy:lock',
- 'deploy:release',
- 'deploy:update_code',
'deploy:clear_paths',
- 'deploy:shared',
// build and upload assets
'app:assets:deploy',
'app:graphql:deploy',
@@ -62,7 +64,6 @@
'deploy:sentry',
'git:tag:add',
'deploy:cache:clear',
- 'deploy:cache:warmup',
'deploy:writable',
// Migrate database before symlink new release.
// 'database:migrate',
@@ -74,13 +75,13 @@
'cachetool:clear:opcache',
// Cleanup and finish the deploy
'deploy:unlock',
- 'cleanup',
+ 'deploy:cleanup',
])->desc('Deploy your project');
// after successful deploy
after('deploy', 'httpcache:invalidate');
after('deploy', 'deploy:log:remote');
-after('deploy', 'success');
+after('deploy', 'deploy:success');
// If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
diff --git a/deploy/files/.env.local.prod b/deploy/files/.env.local.prod
index b19707977..abc7d425a 100644
--- a/deploy/files/.env.local.prod
+++ b/deploy/files/.env.local.prod
@@ -1,12 +1,12 @@
APP_ENV=prod
APP_SECRET=ThisIbexaPlatformTokenIsNotSoSecret_PleaseChangeIt
SERVER_ENVIRONMENT=prod
-DATABASE_URL=mysql://root@localhost/ibexa
+DATABASE_URL=mysql://root@127.0.0.1/ibexa
SEARCH_ENGINE=legacy
HTTPCACHE_PURGE_TYPE=local
-HTTPCACHE_PURGE_SERVER=http://localhost:6081
+HTTPCACHE_PURGE_SERVER=http://127.0.0.1:6081
CACHE_POOL=cache.tagaware.filesystem
-SOLR_DSN=http://localhost:8983/solr
-MAILER_DSN=smtp://localhost
+SOLR_DSN=http://127.0.0.1:8983/solr
+MAILER_DSN=smtp://127.0.0.1
SENTRY_DSN=
MAILER_LITE_API_KEY=
diff --git a/deploy/hosts.php b/deploy/hosts.php
index 89f9d5206..bb536d1b3 100644
--- a/deploy/hosts.php
+++ b/deploy/hosts.php
@@ -3,22 +3,24 @@
namespace Deployer;
host('prod')
- ->hostname('some.server.com')
+ ->setHostname('some.server.com')
->set('deploy_path', '/home/some/example/sites/example.com/htdocs')
- ->stage('prod')
- ->user('exampleweb')
+ ->set('labels', ['stage' => 'prod'])
+ ->setRemoteUser('exampleweb')
->set('http_user', 'exampleweb')
- ->set('cachetool', '/var/run/php/exampleweb.sock')
+ ->set('cachetool', '/run/php/php8.1-fpm.sock')
->add('varnish_ban_hosts', ['www.example.com'])
+ ->set('symfony_env', 'prod')
;
host('stage')
- ->hostname('192.0.2.10')
- ->set('deploy_path', '/var/www/my/project')
- ->stage('stage')
- ->user('deployer')
- ->set('http_user', 'www-data')
+ ->setHostname('some.server.com')
+ ->set('deploy_path', '/home/some/example/sites/example.com/htdocs')
+ ->set('labels', ['stage' => 'stage'])
+ ->setRemoteUser('exampleweb')
+ ->set('http_user', 'exampleweb')
// ->set('branch', 'test-branch') // by default, master is used, this is the way to set up different branch per host
- ->set('cachetool', '/var/run/php/exampleweb.sock')
- ->add('varnish_ban_hosts', ['stage.example.com'])
+ ->set('cachetool', '/run/php/php8.1-fpm.sock')
+ ->add('varnish_ban_hosts', ['www.example.com'])
+ ->set('symfony_env', 'stage')
;
diff --git a/deploy/tasks/assets.php b/deploy/tasks/assets.php
index 9b62c6bc1..b1e11978e 100644
--- a/deploy/tasks/assets.php
+++ b/deploy/tasks/assets.php
@@ -31,19 +31,19 @@
writeln('Checking for changes in asset files. If this fails, commit or stash your changes before deploying.');
$assetResourcePaths = get('asset_resource_paths');
foreach ($assetResourcePaths as $resourcePath) {
- run("git diff --exit-code {$resourcePath}");
+ runLocally("git diff --exit-code {$resourcePath}");
}
$installCmd = get('asset_install_command');
- run($installCmd);
+ runLocally($installCmd);
$buildCmd = get('asset_build_command');
- run($buildCmd);
-})->local();
+ runLocally($buildCmd);
+})->once();
task('app:assets:ibexa:build', function() {
- run("{{asset_ibexa_build_command}}");
-})->local();
+ runLocally('{{asset_ibexa_build_command}}');
+})->once();
task('app:assets:upload', function() {
$assetPaths = get('asset_build_paths');
@@ -51,7 +51,7 @@
$config = [];
foreach ($excludedPaths as $excludedPath) {
- $config['options'][] = "--exclude {$excludedPath}";
+ $config['options'][] = "--exclude= {$excludedPath}";
}
foreach ($assetPaths as $path) {
diff --git a/deploy/tasks/database.php b/deploy/tasks/database.php
index dc2776e67..fcc7ebd92 100644
--- a/deploy/tasks/database.php
+++ b/deploy/tasks/database.php
@@ -4,5 +4,5 @@
desc('Execute kaliop migrations');
task('database:kaliop:migrate', function () {
- run('{{bin/php}} {{bin/console}} kaliop:migration:migrate --env={{symfony_env}}');
+ run('{{bin/console}} kaliop:migration:migrate --env={{symfony_env}}');
});
diff --git a/deploy/tasks/git.php b/deploy/tasks/git.php
index 944ed4872..4fbd8d87d 100644
--- a/deploy/tasks/git.php
+++ b/deploy/tasks/git.php
@@ -18,4 +18,4 @@
runLocally("$git tag -a $tag -m '" . $message . "' " . trim($commitHash));
runLocally("$git push origin $tag");
-})->onStage('prod');
+})->select('stage=prod');
diff --git a/deploy/tasks/graphql.php b/deploy/tasks/graphql.php
index 3ebb0eefb..cc4e57493 100644
--- a/deploy/tasks/graphql.php
+++ b/deploy/tasks/graphql.php
@@ -10,8 +10,8 @@
]);
task('app:graphql:generate', function () {
- run("{{graphql_generate_command}}");
-})->local();
+ runLocally("{{graphql_generate_command}}");
+})->once();
task('app:graphql:upload', function () {
diff --git a/deploy/tasks/logs.php b/deploy/tasks/logs.php
index 295777502..0a41b297d 100644
--- a/deploy/tasks/logs.php
+++ b/deploy/tasks/logs.php
@@ -8,5 +8,5 @@
$result = run('cat '.$file);
- write($result);
+ writeln($result);
});
diff --git a/deploy/tasks/overrides.php b/deploy/tasks/overrides.php
index fad8e3210..8dc01c3be 100644
--- a/deploy/tasks/overrides.php
+++ b/deploy/tasks/overrides.php
@@ -2,9 +2,6 @@
namespace Deployer;
-set('bin/cachetool', function(){
- return 'cachetool-7.0.0.phar';
-});
// overridden to make sure public folder is correctly symlinked (L79)
desc('Rollback to previous release');
@@ -20,9 +17,9 @@
// Remove release
run("rm -rf {{deploy_path}}/releases/{$releases[0]}");
- if (isVerbose()) {
- writeln("Rollback to `{$releases[1]}` release was successful.");
- }
+
+ writeln("Rollback to `{$releases[1]}` release was successful.");
+
} else {
writeln("No more releases you can revert to.");
}
diff --git a/deploy/tasks/rsync.php b/deploy/tasks/rsync.php
index c9ac0b55e..e6717b703 100644
--- a/deploy/tasks/rsync.php
+++ b/deploy/tasks/rsync.php
@@ -39,10 +39,10 @@
return;
}
- $host = $server->getRealHostname();
+ $host = $server->getHostname();
$port = $server->getPort() ? ' -p' . $server->getPort() : '';
$sshArguments = $server->getSshArguments();
- $user = !$server->getUser() ? '' : $server->getUser() . '@';
+ $user = !$server->getRemoteUser() ? '' : $server->getRemoteUser() . '@';
runLocally("rsync -{$config['flags']} -e 'ssh$port $sshArguments' {{rsync_options}}{{rsync_includes}}{{rsync_excludes}}{{rsync_filter}} '$user$host:$src/' '$dst/'", $config);
});
diff --git a/deploy/tasks/server.php b/deploy/tasks/server.php
index 2f80fec17..a80894d22 100644
--- a/deploy/tasks/server.php
+++ b/deploy/tasks/server.php
@@ -17,8 +17,9 @@
}
$stage = null;
- if (input()->hasArgument('stage')) {
- $stage = input()->getArgument('stage');
+ $labels = get('labels');
+ if (array_key_exists('stage', $labels)) {
+ $stage = $labels['stage'];
}
$question = 'Please confirm deploy';
@@ -30,13 +31,14 @@
if(!askConfirmation($question)) {
die("Ok, no deploy then.\n");
}
-})->onStage('prod');
+})->select('stage=prod');
desc('Upload appropriate .env.local file to the server');
task('server:upload_env', function() {
$stage = 'dev';
- if (input()->hasArgument('stage')) {
- $stage = input()->getArgument('stage');
+ $labels = get('labels');
+ if (array_key_exists('stage', $labels)) {
+ $stage = $labels['stage'];
}
$path = get('deploy_path');
@@ -79,7 +81,7 @@ function invalidateFOSHttpCache($tag = null)
{
$tag = !empty($tag) ? $tag : get('http_invalidate_tag');
- run("{{bin/php}} {{bin/console}} fos:httpcache:invalidate:tag {$tag} {{console_options}}");
+ run("{{bin/console}} fos:httpcache:invalidate:tag {$tag} {{console_options}}");
}
desc('Invalidate content on varnish per host');
@@ -124,7 +126,7 @@ function invalidateFOSHttpCache($tag = null)
task('crontab:list', function () {
$result = run('crontab -l');
- write($result);
+ writeln($result);
});
desc('Reindex solr');
diff --git a/deploy/tasks/slack.php b/deploy/tasks/slack.php
index 32df6b83c..2df388c53 100644
--- a/deploy/tasks/slack.php
+++ b/deploy/tasks/slack.php
@@ -8,5 +8,5 @@
/** execution */
before('deploy', 'slack:notify');
-after('success', 'slack:notify:success');
+after('deploy:success', 'slack:notify:success');
after('deploy:failed', 'slack:notify:failure');