【发布时间】:2016-04-29 13:17:47
【问题描述】:
我需要将几个 NodeJS 应用程序部署到在 Microsoft Azure 上运行的 Ubuntu 14.04.4 虚拟机。
我正在使用 shipit 和 shipit-deploy 来完成任务。
到目前为止,我的shipitfile.js 如下所示:
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
var stagingConfig = require('./config.staging').deploy;
var productionConfig = require('./config.prod').deploy;
shipit.initConfig({
default: {
workspace: '/tmp/my-api',
deployTo: '/var/www/my-api',
repositoryUrl: 'https://githubrepoaddresshere.git',
ignores: ['.git', 'node_modules', 'migrations', 'dumpDB', 'logs', 'bin'],
rsync: ['--del'],
keepReleases: 2,
key: '~/.ssh/id_rsa.pem',
shallowClone: true
},
staging: stagingConfig,
production: productionConfig
});
shipit.on('init', function() {
console.log('Starting deployment...');
});
shipit.on('deployed', function () {
// npm install etc etc
});
};
stagingConfig 变量是一个保存环境特定信息的对象:
{
"branch": "develop",
"servers": "username@my-api-staging.northeurope.cloudapp.azure.com"
}
当我运行shipit staging deploy 命令时,我得到
'deploy:update' errored after 3.41 s
Error: Command failed: ssh -i ~/.ssh/id_rsa.pem "username@my-api-staging.northeurope.cloudapp.azure.com" "mkdir -p /var/www/my-api/releases/20160429125114"
mkdir: cannot create directory ‘/var/www/my-api/releases’: Permission denied
我知道我可以:
1) 尝试部署在/home/username
2) Use this workaround 以root 启动ssh 会话。
我仍然必须尝试第一个,并且肯定不愿意使用第二个。
所以我的问题是:是否有一个干净且非 hacky 的解决方案让 shipit-deploy 在部署期间使用 sudo 为它运行的每个命令添加前缀?
【问题讨论】:
标签: node.js azure deployment web-deployment