【问题标题】:How do you set up a continuous deployment pipeline on AWS for a NodeJS project?如何在 AWS 上为 NodeJS 项目设置持续部署管道?
【发布时间】:2020-07-05 10:32:03
【问题描述】:

我正在使用 Elastic Beanstalk 为我的 NodeJS 应用程序提供服务。当我通过生成项目源代码的 .zip 存档手动部署时,它工作得非常好。 zip 文件字面意思包含:

\dist
server.js
request-map.js
credentials.json

现在我正在尝试按照:https://aws.amazon.com/getting-started/tutorials/continuous-deployment-pipeline/ 设置持续部署管道。部署成功,但是当我导航到我的应用程序时,我看到:

Error: ENOENT: no such file or directory, stat '/var/app/current/dist/wisesheet/index.html'

本教程不包含构建阶段,我认为这就是问题所在 - 管道如何知道要部署哪些工件?当然,直接在 repo 中没有 dist 文件夹,因为还没有构建任何内容。那么在我将更改推送到生产分支后,它如何知道要部署什么?

git仓库代码结构如下:

【问题讨论】:

    标签: node.js amazon-elastic-beanstalk devops continuous-deployment aws-codepipeline


    【解决方案1】:

    在部署操作之前使用 CodeBuild 操作添加构建阶段。

    在 CodeBuild 服务中,构建规范是一个文件,其中列出了构建项目的命令。工件部分非常重要,因为您在此处提到的文件/文件夹将被压缩并馈送到下一阶段(您的部署阶段)

    版本:0.2

    phases:
      install:
        commands:
          - npm install -g typescript
      build:
        commands:
          - tsc index.ts
    artifacts:
      files:
        - index.js
    

    我发现此资源在添加构建阶段时可能会对您有所帮助:

    https://levelup.gitconnected.com/build-test-deploy-node-js-app-with-codecommit-codepipeline-codebuild-elastic-beanstalk-c6d89f971ef2

    【讨论】:

      猜你喜欢
      • 2011-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-19
      相关资源
      最近更新 更多