Github - Deploying a Nest.js App to AWS Elastic Beanstalk (Node.js Platform) with Github Actions

Steps

  1. Push code to GitHub

  2. Trigger GitHub Actions to install dependencies and build project

  3. Deploy the project to AWS Elastic Beanstalk

  4. Run script in Procfile (npm run start:prod)

What do we need?

  1. Procfile - Add Procfile to your Nest.js Application

  2. .ebignore - Add .ebignore to your Nest.js Application

  3. PORT - Let your Nest.js Application listening port match to Elastic Beanstalk proxy forwarding port

  4. GitHub Workflow files

Add Procfile to the root of your Nest.js Application

Procfile
web:npm run start:prod

Add .ebignore to the root of your Nest.js Application

.ebignore
/node_modules

Set Environment Variable PORT to 8080 at Elastic Beanstalk - Config

If your application listening to process.env.PORT, then you can set Elastic Beanstalk Config PORT to any port. Otherwise, set your application listening port to 8080 to match the default proxy forwarding port.

By default, Elastic Beanstalk configures the proxy to forward requests to your application on port 8080. You can override the default port by setting the PORT environment property to the port on which your main application listens.

GitHub Workflow files

Last updated

Was this helpful?