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',
]);
@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