php - 部署者:从没有存储库的本地机器部署
问题描述
所以我正在尝试使用部署器将我的本地文件部署到服务器。
但是我不确定部署程序究竟是如何工作的,因为它似乎需要一个 GIT 存储库——我不想使用它。在文档中,我真的找不到很多关于我的问题的信息。
我的问题: 如何在没有 git-repository 的情况下使用部署程序。只需将我的本地文件推送到服务器/多个服务器。
我使用安装了部署程序的 Symfony4,一切正常,直到出现以下错误:
fatal: repository '/var/www/project/releases/1' does not exist
谢谢
部署者.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);
}
});
推荐阅读
- templates - Typo3 OnePager 使用 Fluidtemplate 加载内容
- c# - Asp.net core 2.0 错误 -13 EACCES 权限被拒绝
- django - 引导按钮菜单响应在 Django 项目中不起作用
- javascript - 使用 css 和 javascript 淡出元素在页面中留下空白空间
- json - ssis 输出 json 文件添加额外的 crlf
- c - 在字符串中的每个逗号后添加双引号
- php - 当需要服务器响应时,消除确认对话框的等待时间
- javascript - How to search data in a table in HTML
- regex - Rust regex pattern - unrecognized escape pattern
- android - Ionic:使用 cordova-plugin-inappbrowser 拦截 PDF URL