所以我想用 deployer将我的本地文件部署到服务器。
但是我不确定部署程序究竟是如何工作的,因为它似乎需要一个 GIT 存储库 - 我不想使用它。在文档中,我真的找不到关于我的问题的太多信息。
我的问题:
如何在没有 git-repository 的情况下使用部署程序。只需将我的本地文件推送到服务器/多个服务器。
我使用安装了部署程序的 Symfony4,一切正常,直到出现以下错误:
fatal: repository '/var/www/project/releases/1' does not exist
谢谢
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');
最佳答案
如上所述,您可以使用 rsync 配方或简单地覆盖 deploy:update_code
像这样:
task('deploy:update_code', function () {
writeln("<info>Uploading files to server</info>");
upload('./< some path >', '{{release_path}}');
});
有时我只需要将一些文件推送到远程,我为此创建了一个任务:
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);
}
});
关于php - 部署者 : Deploy from local machine without repository,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57304610/