【问题标题】:Is it possible to deploy using "pm2 deploy production" on Bitbucket Pipelines?是否可以在 Bitbucket Pipelines 上使用“pm2 deploy production”进行部署?
【发布时间】:2018-05-25 10:53:59
【问题描述】:

我正在尝试使用 Bitbucket Pipelines 使用 pm2 deploy production 命令进行部署。

我想知道是否可以这样做吗?因为有一个选项可以在 Bitbucket 中添加现有的 ssh 密钥,但它要求同时提供公钥和私钥,而我只有一个私钥。

deploy: {
    production: {
        user: "ubuntu",
        host: "ec2-xx-xxx-xxx-xx.us-east-2.compute.amazonaws.com",
        key: "~/.ssh/myKey.pem",
        ref: "origin/master",
        repo: "git@bitbucket.org:User/myProject.git",
        path: "/home/ubuntu/myProject",
        "post-deploy":
            "npm install && pm2 startOrRestart ecosystem.config.js"
    }   
}

这是我的 PM2 部署配置,我在 package.json 中使用它,

"scripts": {
    "deploy": "pm2 deploy ecosystem.config.js production"
}

我的 bitbucket 管道文件命令如下。

script: # Modify the commands below to build your repository.
          - npm install
          - npm run-script deploy

我将它托管在 AWS EC2 实例中,我只有 PEM 密钥来将它与我的 EC2 实例连接。

【问题讨论】:

    标签: amazon-ec2 deployment bitbucket pm2 bitbucket-pipelines


    【解决方案1】:

    是的,你可以。 而不是这个:

    "scripts": {
      "deploy": "pm2 deploy ecosystem.config.js production"
    }
    

    在项目中安装pm2并像这样运行:

    "scripts": {
      "deploy": "./node_modules/pm2/bin/pm2 deploy ecosystem.config.js production"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-22
      • 2018-10-07
      • 2016-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多