nodejs (Nest Js) AWS Elasti c Beanstalk Issue (с конвейером aws) - PullRequest
0 голосов
/ 04 августа 2020

У меня много раз были красные документы, и у меня все еще есть проблема с развертыванием моего проекта на Elasti c Beanstalk. Я создал готовое решение для сборки, которое без проблем работает на моем локальном компьютере. Структура выглядит так: enter image description here

also I have created pipeline as AWS service:

enter image description here

acording to doccumentation i created buildspec.yaml file: (it just creates dist folder, puts files into it, install node_modules takes togeher and makes zip file)

version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 12
    commands:
      - yum install -y zip
      - echo "Instal dependencies"
      - npm install
  build:
    commands:
      - npm run build
      - cd dist
      - zip -r application.zip ./* ../package.json ../package-lock.json ../.env ../node_modules ../Procfile
      - cd ..
      - mv ./dist/application.zip ./
artifacts:
  files:
    - application.zip

It creates artifact as zip and puts into E3 bucket when i download it the structure is the same as in my local computer: enter image description here

According to docs i have included Procfile which is used during delploy action:

web: node app.js

The problem accurs during deployment. I receive error from Elastic Beanstalk:

2020/08/04 16:58:49.766428 [INFO] Executing instruction: StageApplication
2020/08/04 16:58:49.917998 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/08/04 16:58:49.918039 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/08/04 16:58:50.544212 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/08/04 16:58:50.544764 [INFO] Executing instruction: RunPreBuildHooks
2020/08/04 16:58:50.544792 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
2020/08/04 16:58:50.544797 [INFO] Executing instruction: Install customer specified node.js version
2020/08/04 16:58:50.544802 [INFO] installing specified nodejs version...
2020/08/04 16:58:50.544809 [INFO] there is no package.json file, skip installing specified version of nodejs
2020/08/04 16:58:50.544814 [INFO] Executing instruction: Use NPM to install dependencies
2020/08/04 16:58:50.544822 [INFO] there is no package.json file, skip installing dependencies
2020/08/04 16:58:50.544827 [INFO] Executing instruction: check Procfile
2020/08/04 16:58:50.544831 [INFO] checking Procfile
2020/08/04 16:58:50.544837 [INFO] no Procfile found, generating Procfile
2020/08/04 16:58:50.544841 [INFO] checking package.json file
2020/08/04 16:58:50.544847 [INFO] checking app.js file from source
2020/08/04 16:58:50.544853 [INFO] checking server.js file from source
2020/08/04 16:58:50.544867 [ERROR] An error occurred during execution of command [app-deploy] - [check Procfile]. Stop running the command. Error: node.js may have issues starting. Please provide a package.json file or add server.js/app.js file in source bundle 

In my opinion deploy pipeline part does not recive artifacts because it does not see package.json, Procfile and also app.js main file.

In addtion I would like to show you that i have established artifacts connection between deploy and build section: введите описание изображения здесь

Когда загружаю файл вручную - работает .. Что я делаю не так? Спасибо за совет!

...