您如何在AWS上为NodeJS项目设置连续部署管道?

问题描述 投票:0回答:1

我正在使用Elastic Beanstalk服务我的NodeJS应用程序。当我通过生成项目源代码的.zip存档进行手动部署时,它工作得很好。压缩文件literally包含:

\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'

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

git储存库代码结构如下:enter image description here

node.js amazon-elastic-beanstalk devops continuous-deployment aws-codepipeline
1个回答
0
投票

在部署操作之前添加带有CodeBuild操作的构建阶段。

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

版本: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

© www.soinside.com 2019 - 2024. All rights reserved.