0

我现在部署和更新我的 craft 3 站点的方式是将我的 git 存储库中的更改推送到服务器上的一个裸存储库,该存储库有一个接收后挂钩来执行此操作:

#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/www git checkout -f
cd /home/ubuntu/www && composer install --no-interaction --prefer-dist --optimize-autoloader

但我似乎无法获得正确的权限。Git 将覆盖文件模式,以便网络服务器无法写入它需要的目录。

有没有我应该部署的不同方式或防止权限混乱的方式?

4

1 回答 1

1

您应该查看https://deployer.org以通过 git 部署craftcms,这就是我这样做的方式,修复了所有权限问题。部署器配置可能如下所示:

<?php
namespace Deployer;

require 'recipe/common.php';

// Project name
set('application', 'my_project');

// Project repository
set('repository', 'git@gitlab.com/website.git');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true); 

// Shared files/dirs between deploys 
set('shared_files', ['.env','config/license.key']);
set('shared_dirs', ['web/uploads', 'storage/logs', 'storage/backups']);

// Writable dirs by web server 
set('writable_dirs', ['web/uploads', 'storage/runtime', 'storage/logs', 'storage/backups', 'storage/runtime', 'web/cpresources']);
set('allow_anonymous_stats', false);

// releases
set('keep_releases', 3);

// Hosts

host('staging')
    ->hostname('example.com')
    ->port(22)
    ->user('root')
    ->set('deploy_path', '/var/www/staging'); 

host('production')
    ->hostname('example.com')
    ->port(22)
    ->user('root')
    ->set('deploy_path', '/var/www/html');   


// Tasks

desc('Deploy your project');
task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'deploy:writable',
    'deploy:vendors',
    'deploy:clear_paths',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
    'success'
]);

after('deploy:failed', 'deploy:unlock');
于 2019-03-13T09:53:42.057 回答