php - 部署者 : Deploy from local machine without repository

标签 php symfony php-deployer

所以我想用 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/

相关文章:

php - 获取模拟 Doctrine\ORM\QueryBuilder

php - 通过网站数据库的 Paypal - 这可能吗?

php - 将所有行从一个表移动到另一个表,从原始表中删除但保留 auto_increment

Java:在 Mac 上创建一个具有 777 权限的新目录

php - 自动更新出价 - PHP/Ajax

symfony - 如何使用 Symfony HttpClient 获取所有中介重定向

php - 如何为 Symfony2 中的所有 Controller 添加一些路由前缀?

ssh - 警告 : Identity file/home/user/. ssh/id_rsa 不可访问:没有这样的文件或目录

symfony - 回滚 Doctrine :migrations with Deployer

PHP Deployer 更改 Composer 版本