-
Notifications
You must be signed in to change notification settings - Fork 203
Deprecate local recipe #125
Comments
This seems like a sane idea. Main motivation behind local recipe was that
`common` recipe was remote-server exclusive ;)
Plus your proposed handling of groups is perfect for my main use-case and
sole reason for rsync recipe to exist :)
2017-04-04 8:52 GMT+02:00 Anton Medvedev <notifications@github.com>:
… Now local recipe is a copy of common recipe with replaced run calls by
runLocally calls.
I would like to leave only one copy of those recipes – common. To do so,
in Deployer v5 was introduced task(...)->local() api.
@johnny-bit <https://github.com/johnny-bit> @nickdenardis
<https://github.com/nickdenardis> let's talk about it.
For example, to make a task local:
task('deploy:update_code')->local();task('deploy', [ 'deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:vendors', 'deploy:symlink',]);
But now it will not work, because localhost created inside SeriesExecutor
<https://github.com/deployphp/deployer/blob/master/src/Executor/SeriesExecutor.php#L52>
and you can't set proper deploy_path for it.
Maybe to solve it lets run all local tasks on first localhost if
deployer->hosts? Then this will be possible:
localhost()->set('deploy_path', '/some/build/path');
Main goal to achieve easily configuration of tasks.
For example. Simple recipe there deploy process split into two phases:
build and deploy:
task('build', [ 'deploy:update_code', 'deploy:vendors', 'yarn:install', 'npm:build', 'deploy:clear_paths',])->local();task('deploy', [ 'deploy:prepare', 'deploy:release', 'rsync', 'deploy:shared', 'deploy:writable', 'deploy:symlink', 'cleanup', 'success']);before('deploy', 'build');
But now it does not work, group tasks doesn't supports become local. (what
to do if one task persists in two groups: one local, one remote?)
So, what I propose to do:
- Run all local() task on first defined localhost()
- Allow group task to become local
- Check all common task if they can be ran locally and what config
they require
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#125>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKMVFd_F-A-zJNZqBBAeYCPTkg6DWkIoks5rseimgaJpZM4Myc-j>
.
--
Pozdrawiam,
Hubert Kowalski
|
I agree with @johnny-bit this sounds like a good idea. I'm not as familiar with the inner workings of deployer, need to get up to speed with the v5 codebase. But that two phase example you provided is spot on! |
I found a nice solution without complicating code. I think what build always should be performed on one host. task('build', function () {
set('deploy_path', __DIR__ . '/.build');
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
invoke('deploy:vendors');
$releasePath = get('release_path');
on(Deployer::get()->hosts, function () use ($releasePath) {
set('build_path', "$releasePath/");
});
})->local();
task('upload', function () {
upload('{{build_path}}', '{{release_path}}');
});
task('deploy', [
'deploy:prepare',
'deploy:release',
'upload',
'deploy:shared',
'deploy:writable',
'deploy:symlink',
'cleanup',
'success'
]);
before('deploy', 'build'); And this is already working! More, it's possible to specify different host for as build machine(!) not only localhost. task('build', function () {
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
invoke('deploy:vendors');
$releasePath = get('release_path');
on(roles('app'), function () use ($releasePath) {
set('build_path', "$releasePath/");
});
})->onRoles('build'); |
Hmm... At first it was hard to follow, but then I have to agree. I mean -
in some of my deploys code is being build on cluster of hosts, but that's
with DistCC... So yeah, build host can be single with one or multiple
destination hosts... And I believe a bit of tinkering would achieve perfect
spread, eg: one build host, one host to receive "assests" and broadcast
them to cdn, another host to receive buildables, another host to receive db
updates... Yeah, this could work. More thinking and tinkering.
I guess we would benefit from creating examples and/or documenting use
cases. That way many people would find it easier to follow.
2017-04-08 11:19 GMT+02:00 Anton Medvedev <notifications@github.com>:
… I found a nice solution without complicating code. I think what build
always should be performed on one host.
task('build', function () { set('deploy_path', __DIR__ . '/.build'); invoke('deploy:prepare'); invoke('deploy:release'); invoke('deploy:update_code'); invoke('deploy:vendors'); $releasePath = get('release_path'); on(Deployer::get()->hosts, function () use ($releasePath) { set('build_path', "$releasePath/"); });})->local();task('upload', function () { upload('{{build_path}}', '{{release_path}}');});task('deploy', [ 'deploy:prepare', 'deploy:release', 'upload', 'deploy:shared', 'deploy:writable', 'deploy:symlink', 'cleanup', 'success']);before('deploy', 'build');
And this is already working! More, it's possible to specify different host
for as build machine(!) not only localhost.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#125 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKMVFSl2sn-gOMAVAgVEksTSlEzcnEeaks5rt1EvgaJpZM4Myc-j>
.
--
Pozdrawiam,
Hubert Kowalski
|
Or even simpler(!) task('build', function () {
set('deploy_path', __DIR__ . '/.build');
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
invoke('deploy:vendors');
invoke('deploy:symlink');
})->local();
task('upload', function () {
upload(__DIR__ . "/.build/current/", '{{release_path}}');
});
task('deploy', [
'build',
'deploy:prepare',
'deploy:release',
'upload',
'deploy:shared',
'deploy:writable',
'deploy:symlink',
'cleanup',
'success'
]); Works as a charm. |
Docs will be there: https://github.com/deployphp/docs/blob/master/advanced/deploy-strategies.md |
Migrating from "old" ways would be great too ;) |
@johnny-bit can you write about it in UPGRADE.md later? :) |
Someone should do just that :) I'll do that if I have time. No promises,
but I'll try :)
2017-04-08 12:27 GMT+02:00 Anton Medvedev <notifications@github.com>:
… @johnny-bit <https://github.com/johnny-bit> can you write about it in
UPGRADE.md <https://github.com/deployphp/recipes/blob/master/UPGRADE.md>
later? :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#125 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKMVFRSdMb4JkaSHmVJvphRIjDX4fEGyks5rt2EMgaJpZM4Myc-j>
.
--
Pozdrawiam,
Hubert Kowalski
|
I really like the direction of this! The deploy path switching makes sense now that I see the second example, much cleaner. If I can help let me know, I may have some time in the next week or two, hopefully. |
@nickdenardis will be cool if you can write new article about new local deploy strategy. Also planning to release v5 on next weeks. |
@antonmedv for sure, not a problem :) |
Hello, thank you for this helpful thread. How difficult would it be to add a This would enable us to transform task('build', function () {
set('deploy_path', __DIR__ . '/.build');
invoke('deploy:prepare');
invoke('deploy:release');
invoke('deploy:update_code');
invoke('deploy:vendors');
invoke('deploy:symlink');
})->local(); into task('build', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:vendors',
'deploy:symlink',
])->local()->set('deploy_path', __DIR__ . '/.build'); As an alternative we could let the task('build', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:vendors',
'deploy:symlink',
])->local(__DIR__ . '/.build'); What do you think? 🙂 |
I came out with better solution for local builds for v7. Will be simple and instead of adding set on tasks. Just need to find time to implement it) now all my free time in Deployer Pro project. Hope to get some money to support open source development. |
Cool, looking forward to see that. No problem take you time :) |
Now local recipe is a copy of common recipe with replaced
run
calls byrunLocally
calls.I would like to leave only one copy of those recipes – common.
To do so, in Deployer v5 was introduced
task(...)->local()
api.@johnny-bit @nickdenardis let's talk about it.
For example, to make a task local:
But now it will not work, because localhost created inside SeriesExecutor and you can't set proper
deploy_path
for it.Maybe to solve it lets run all local tasks on first localhost if deployer->hosts? Then this will be possible:
Main goal to achieve easily configuration of tasks.
For example. Simple recipe there deploy process split into two phases: build and deploy:
But now it does not work, group tasks doesn't supports become local. (what to do if one task persists in two groups: one local, one remote?)
So, what I propose to do:
Run alllocal()
task on first definedlocalhost()
Allow group task to become localCheck all common task if they can be ran locally and what config they requireThe text was updated successfully, but these errors were encountered: