Skip to content

Instantly share code, notes, and snippets.

@maxgfr
Last active June 13, 2023 21:15
Show Gist options
  • Save maxgfr/1df86e21ae01a7fb9acbb429839c66fb to your computer and use it in GitHub Desktop.
Save maxgfr/1df86e21ae01a7fb9acbb429839c66fb to your computer and use it in GitHub Desktop.
Configuration for NextJS for AWS pipeline (Github webhook - Codebuild - Elastic Beanstalk)
version: 0.2
phases:
install:
commands:
- echo Installing dependency...
- npm install -g next
- yarn
pre_build:
commands:
- printenv > .env
build:
commands:
- echo Compiling the Node.js code
- yarn build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- '**/*'
{
"scripts": {
"start": "node server.js"
}
}
const cli = require('next/dist/cli/next-start');
cli.nextStart([
'-p', process.env.PORT || 3000,
'-H', process.env.HOSTNAME || '0.0.0.0',
]);
@kareemdarkazanli
Copy link

This solved my issue - thank you!

@tcagkansokmen
Copy link

Hello there, It works well.

Buy I couldn't connect my domain to the EBS.
I added alias from route 53.
And then, I added new listener to the load balancer, for HTTPS. And added my certificate (that works for another projects).

But It can not connect. What could be wrong with that?

@younes-alouani
Copy link

I guess you need to configure port to 80 for http requests.

@rishi-singh26
Copy link

works like a charm

@manuelsechi
Copy link

Using

- '**/*'

you copy over every file, including the node_modules folder. is there a way to only copy the .next folder with the builded code?

@crjrdemant
Copy link

for those wondering about @manuelsechi comment

yes, you can with the following:

artifacts:
  base-directory: 'out'
  files:
    - "**/*"

@manuelsechi
Copy link

@crjrdemant not sure what "out" is
next.js usually puts builded files into the .next dir.

can you better explain please?

@vurcease
Copy link

@manuelsechi I am brand new to Next.js, just started my first project. Using the latest version of Next.js the documentation to generate output files for a static website (no Node backend) instructs you to configure next.config.js to have this:

const nextConfig = { output: 'export' }

This will build out the static-website ready files in the /out directory. Might be something with newer versions of Next.js? Or perhaps this is exclusively the output directory for no-backend static files. Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment