I am using NextJS and attempting to do CI to build and deploy onto AWS Beanstalk.
This is my buildspec.yml
version: 0.2
env:
variables:
NODE_ENV: "production"
phases:
pre_build:
commands:
- echo Installing dependencies
- npm install
build:
commands:
- echo Building nextjs app
- npm run build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'
I am monitoring the logs and there are no errors, but there are no artifacts being produced by the Build stage. So once the pipeline moves onto the Deploy stage. I get this error in the logs:
----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Nov 30 01:47:31 ip-172-31-50-67 web: at /var/app/current/node_modules/next/dist/bin/next:26:341
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! code ELIFECYCLE
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! errno 1
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! with-typescript@1.0.0 start: `next start`
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! Exit status 1
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR!
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! Failed at the with-typescript@1.0.0 start script.
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! A complete log of this run can be found in:
Nov 30 01:47:31 ip-172-31-50-67 web: npm ERR! /home/webapp/.npm/_logs/2020-11-30T01_47_31_607Z-debug.log
Nov 30 01:47:32 ip-172-31-50-67 web: > with-typescript@1.0.0 start /var/app/current
Nov 30 01:47:32 ip-172-31-50-67 web: > next start
Nov 30 01:47:32 ip-172-31-50-67 web: Error: Could not find a valid build in the '/var/app/current/.next' directory! Try building your app with 'next build' before starting the server.
Nov 30 01:47:32 ip-172-31-50-67 web: at Server.readBuildId (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:137:355)
Nov 30 01:47:32 ip-172-31-50-67 web: at new Server (/var/app/current/node_modules/next/dist/next-server/server/next-server.js:3:120)
Nov 30 01:47:32 ip-172-31-50-67 web: at createServer (/var/app/current/node_modules/next/dist/server/next.js:2:638)
Nov 30 01:47:32 ip-172-31-50-67 web: at start (/var/app/current/node_modules/next/dist/server/lib/start-server.js:1:323)
Nov 30 01:47:32 ip-172-31-50-67 web: at nextStart (/var/app/current/node_modules/next/dist/cli/next-start.js:19:125)
I don't understand what more I can do? I have tried changing the Artifacts settings for the Build stage to encrypted and unencrypted, I have tried No cache, Local, and Amazon S3 with a Cache Bucket. None of these seem to produce any artifacts.
Can anyone point me to what I'm doing wrong?