So I am trying to use deployer to deploy my local files to a server.
However I am not sure how deployer exactly works, because it seems like it needs a GIT repository - which I do not want to use. In the documentation I can't really find much information about my issue.
My Question: How do I use deployer without git-repository. Just push my local files to the server / multiple servers.
I use Symfony4 with deployer installed and everything works fine until following error:
fatal: repository '/var/www/project/releases/1' does not exist
Thanks
deployer.php
<?php
namespace Deployer;
require 'recipe/symfony.php';
// Project name
set('application', 'project');
// Project repository
//set('repository', '');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
set('allow_anonymous_stats', false);
// Hosts
host('x.x.x.x') //IP of host
->user('www-data')
->set('deploy_path', '/var/www/project');
// Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'database:migrate');
Like stated above, you can use the rsync recipe or simply override the deploy:update_code
with something like this:
task('deploy:update_code', function () {
writeln("<info>Uploading files to server</info>");
upload('./< some path >', '{{release_path}}');
});
Sometimes I just need to push some files to remote and I created a task for that purpose:
use Symfony\Component\Console\Input\InputOption;
option('source', null, InputOption::VALUE_OPTIONAL, 'Source alias of the current task.');
option('target', null, InputOption::VALUE_OPTIONAL, 'Target alias of the current task.');
task('upload:file', function() {
/*
* Usage: dep upload:file --source="some_destination/file.txt" --target="some_destination/" host
*/
$source = null;
$target = null;
if (input()->hasOption('source')) {
$source = input()->getOption('source');
}
if (input()->hasOption('target')) {
$target = input()->getOption('target');
}
if (askConfirmation('Upload file ' . $source . ' to release/' . $target . ' ?')) {
upload('/< some place >' . $source, '{{release_path}}/' . $target);
}
});